php-debugbar
php-debugbar copied to clipboard
Redis storage: fields do not expire leading to eventual OOM errors
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.
I've noticed that too. If changing from hset()
to setex()
is not good, one could still set a TTL in the hash.
Any comments on this? I just turned this on in our staging environment and suddenly our Redis cache got pretty filled up.