首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复laravel no command 'Redis::throttle'?

如何修复laravel no command 'Redis::throttle'?
EN

Stack Overflow用户
提问于 2019-06-20 11:43:34
回答 1查看 614关注 0票数 1

我只使用了文档示例,但得到了错误exception 'Predis\ClientException' with message 'Command 'THROTTLE' is not a registered Redis command.

我搜索了很多关于redis命令的东西,但是没有关于throttle的。

代码语言:javascript
复制
 public function handle()
    {
        // Allow only 2 emails every 1 second
        Redis::throttle('my-mailtrap')->allow(2)->every(1)->then(function () {

            $recipient = 'steven@example.com';
            Mail::to($recipient)->send(new OrderShipped($this->order));
            Log::info('Emailed order ' . $this->order->id);

        }, function () {
            // Could not obtain lock; this job will be re-queued
            return $this->release(2);
        });
    }

我该怎么做?有什么帮助吗,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-20 12:24:36

Illuminate/Redis/Connections/PredisConnection中定义了throttle方法。

Redis外观允许您使用以下命令获取连接

代码语言:javascript
复制
Redis::connection()
    ->throttle('my-mailtrap')
    //...

http://laravel.com/docs/5.8/redis

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56678665

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档