php-debugbar icon indicating copy to clipboard operation
php-debugbar copied to clipboard

Redis storage: fields do not expire leading to eventual OOM errors

Open hackel opened this issue 8 years ago • 2 comments

I originally reported this in barryvdh/laravel-debugbar#417 but I see that the problem is actually in php-debugbar. Storage data is being stored in a single key as a Redis hash (HSET), with each session as an individual field. I think it makes much more sense to store each session as a separate key with a timeout, the way the Laravel session driver works. Basically, instead of

$this->redis->hset($this->hash, $id, serialize($data));

in \DebugBar\Storage\RedisStorage::save, use:

$this->redis->setex($this->hash.$id, $timeout, serialize($data));

(Along with changing the other respective methods.) Thoughts? I'm happy to do a PR if you think this is a good idea.

hackel avatar Nov 18 '15 00:11 hackel

I've noticed that too. If changing from hset() to setex() is not good, one could still set a TTL in the hash.

igorsantos07 avatar Jan 13 '20 05:01 igorsantos07

Any comments on this? I just turned this on in our staging environment and suddenly our Redis cache got pretty filled up.

jdavidbakr avatar Aug 05 '22 12:08 jdavidbakr