Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. // in app/Providers/AppServiceProvider...
  2. public function register()
  3. {
  4. $app = $this->app;
  5.  
  6. $app->bind('quota.storage', function($app, $params){
  7. return new FileStorage($params['path']);
  8. });
  9.  
  10. $app->bind('quota.rate', function($app, $params){
  11. return new Rate($params['limit'], $params['period']);
  12. });
  13.  
  14. $app->bind('quota.bucket', function($app, $params){
  15. return new TokenBucket($params['capacity'], $params['rate'], $params['storage']);
  16. });
  17.  
  18. $app->bind('quota.blocker', function($app, $params){
  19. return new BlockingConsumer($params['bucket']);
  20. });
  21. }
  22.  
  23.  
  24.  
  25. //$artisan tinker
  26. Psy Shell v0.7.2 (PHP 5.6.17-0+deb8u1 — cli) by Justin Hileman
  27. >>> use App;
  28. => null
  29. >>> $storage = App::make('quota.storage', ['path' => '/tmp/teststorage']);
  30. => bandwidthThrottle\tokenBucket\storage\FileStorage {#635}
  31.  
  32. >>> $storage->remove();
  33. => null
  34. >>> unset($storage);
  35. => null
  36.  
  37. >>>quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement