maximebf / php-debugbar

Debug bar for PHP
phpdebugbar.com
MIT License
4.2k stars 401 forks source link

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

Open hackel opened 8 years ago

hackel commented 8 years ago

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.

igorsantos07 commented 4 years ago

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

jdavidbakr commented 2 years ago

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