Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // in app/Providers/AppServiceProvider...
- public function register()
- {
- $app = $this->app;
- $app->bind('quota.storage', function($app, $params){
- return new FileStorage($params['path']);
- });
- $app->bind('quota.rate', function($app, $params){
- return new Rate($params['limit'], $params['period']);
- });
- $app->bind('quota.bucket', function($app, $params){
- return new TokenBucket($params['capacity'], $params['rate'], $params['storage']);
- });
- $app->bind('quota.blocker', function($app, $params){
- return new BlockingConsumer($params['bucket']);
- });
- }
- //$artisan tinker
- Psy Shell v0.7.2 (PHP 5.6.17-0+deb8u1 — cli) by Justin Hileman
- >>> use App;
- => null
- >>> $storage = App::make('quota.storage', ['path' => '/tmp/teststorage']);
- => bandwidthThrottle\tokenBucket\storage\FileStorage {#635}
- >>> $storage->remove();
- => null
- >>> unset($storage);
- => null
- >>>quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement