compwright / php-session

Standalone session implementation that does not rely on the PHP session module or the $_SESSION global, ideal for Swoole or ReactPHP applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache TTL option

yani opened this issue · comments

commented

Currently, there is no TTL for sessions stored in the cache.

My custom Redis cache is filling up because sessions are not removed after a set amount of time.

These are controlled by the gcMaxLifetime config option. See

protected int $gc_maxlifetime = 1440;

commented

It doesn't seem to be used.

It's used, check your config maybe? Note that RedisHandler extends ScrapbookHandler.

return $this->store->set($id, $data, $this->config->getGcMaxLifetime());

commented

Oh I see. I'm using Symfony's RedisAdapter as my PSR6 and PSR16 Cache. It has a default lifetime of infinite. I changed it and the Session TTL also changed.

Wouldn't it be better to set the TTL when creating the Session in the cache?

PSR-16 CacheInterface:

public function set($key, $value, $ttl = null);