问题描述
我正在尝试通过 Laravel
中的 redis
来缓存我的结果
I am trying to cache my results using redis
in Laravel
by doing this
$result = Cache::remember('orders_cache', 10, function () use ($orders) {
return $orders;
});
return $result;
当我进入Redis-Cli并执行 KEYS *
时,在那里没有看到 orders_cache
键.我已经在我的 .env
中将 cache_driver
设置为 redis
,并且我还运行了 php artisan config:cache
命令.我还使用composer安装了predis软件包.
When I go in my Redis-Cli and do KEYS *
, I don't see orders_cache
key there. I have set the cache_driver
to redis
in my .env
and I also ran the command php artisan config:cache
. I have also installed predis package using composer as well.
我的开发环境是:
- PHP7.4
- Ubuntu 20
- Laravel 6.0
- Redis 5.0.7
在此方面的任何帮助将不胜感激.TIA
Any help on this would be appreciated.TIA
推荐答案
Redis实例支持16个逻辑数据库,编号从0到15,默认情况下,由Runnig redis-cli
连接到数据库 0
.您可以利用Redis INFO命令来显示包含密钥以及其他更多信息的数据库,例如:
Redis instance supports 16 logical databases and numbered from 0 to 15, by default by runnig redis-cli
you connect to database 0
. you can take advantage of the Redis INFO command to show databases that contain keys and also another more info like:
db0:keys=1,expires=0,avg_ttl=0
db1:keys=2,expires=2,avg_ttl=2462100
在可能的情况下,我有2个数据库.现在,您可以在连接后使用 select
命令更改正在使用的数据库.例如:
That in may case, I have 2 database. now you can change the database you’re using with the select
command after you connect. for example:
select 1
,如果切换成功,它将返回 OK
.现在您可以看到您的laravel键.
and it will return OK
if the switch is successful. now you can see your laravel keys.
这篇关于Redis CLI未显示通过Laravel最近存储的密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!