laravel - 缓存 Redis 'Exception',消息为 'Serialization of ' Closure' is not allowed'

标签 laravel laravel-4 redis

不可能为这个查询做缓存:

Cache::remember('Article.'.$cat_id.$order_by.$sort, $cache_minute, function() use($cat_id, $order_by, $sort)
{
    return Article::where('cat_id','=', $cat_id)
    ->where('published_at', '<=', new DateTime('now'))
    ->with('cat', 'comments')
    ->orderBy($order_by, $sort)
    ->paginate(Config::get('view.paginate_items'))
});

看起来闭包是序列化的。

拜托,关于原因或如何缓存的想法?

最佳答案

您可以使用 ->remember() 函数将查询缓存 x 分钟。

本题解说over here by Franz

关于laravel - 缓存 Redis 'Exception',消息为 'Serialization of ' Closure' is not allowed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16869294/

相关文章:

Laravel 4 迁移模式 - 索引长度

php - laravel 只接受字符串中的第一个字符

python - 为什么 celery 任务不起作用?

php - Laravel Eloquent 关系获取记录到第三级关系

php - Laravel artisan 迁移错误

Laravel:支持更改框架/应用程序文件夹位置的方法吗?

php - Laravel - 从第三个关系开始计数

node.js - Express 和 Redis session 的过期时间

go - 带有Websocket和Redis的多房间聊天应用程序

database - 错误 : Could not open input file: partisan