I have a question about Redis caching.
I wrote some code to cache some information and it works fine, but is there a way to check what’s being stored inside of it through redis-cli
? I just want to make sure that the value gets deleted after 10 minutes.
how I store stuff:
Cache::store('redis')->put('inventory_' . $this->user->steamid64, $items, 15);
2
Answers
Enter the
redis-cli
and use:keys *
to see list of all keysTTL my_key_name
to see remaining expire time of the keyYou can execute any of Redis commands inside of the redis-cli. It’s good tool for development.
Since you are using laravel’s
Cache
class instead ofRedis
– then you need to check for theprefix
. By default it ships like this in config/cache.phpIf there is a prefix(and it is
laravel
) it is going to be like this (if there is no prefix then you may discardlaravel:
from the key names)For the “development” purpose you may also use
monitor
command to see which commands are executed in redis. It is going to print like this;Side note: You don’t need to call
store
method if your default cache driver is already redis.