From a10b76548b48b7ffa29895fda8bcf3ef54c473bc Mon Sep 17 00:00:00 2001 From: iclukas <1122393+iclukas@users.noreply.github.com> Date: Tue, 27 May 2025 10:36:52 +0200 Subject: [PATCH 1/2] leave expiration handling to Redis and make use of the EXAT option, fixes #433 and #422 --- src/Stash/Driver/Redis.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Stash/Driver/Redis.php b/src/Stash/Driver/Redis.php index dd82bf52..5d7e081c 100644 --- a/src/Stash/Driver/Redis.php +++ b/src/Stash/Driver/Redis.php @@ -198,20 +198,11 @@ public function getData($key) */ public function storeData($key, $data, $expiration) { - $store = serialize(array('data' => $data, 'expiration' => $expiration)); + $store = array('data' => $data, 'expiration' => $expiration); if (is_null($expiration)) { return $this->redis->set($this->makeKeyString($key), $store); - } else { - $ttl = $expiration - time(); - - // Prevent us from even passing a negative ttl'd item to redis, - // since it will just round up to zero and cache forever. - if ($ttl < 1) { - return true; - } - - return $this->redis->setex($this->makeKeyString($key), $ttl, $store); } + return $this->redis->set($this->makeKeyString($key), $store, array('EXAT' => $expiration)); } /** From 32334793c0674181be6dedddf0385ee1d6115c32 Mon Sep 17 00:00:00 2001 From: iclukas <1122393+iclukas@users.noreply.github.com> Date: Tue, 27 May 2025 10:38:25 +0200 Subject: [PATCH 2/2] leave expiration handling to Redis and make use of the EXAT option, fixes #433 and #422 --- src/Stash/Driver/Redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stash/Driver/Redis.php b/src/Stash/Driver/Redis.php index 5d7e081c..cb5db905 100644 --- a/src/Stash/Driver/Redis.php +++ b/src/Stash/Driver/Redis.php @@ -198,7 +198,7 @@ public function getData($key) */ public function storeData($key, $data, $expiration) { - $store = array('data' => $data, 'expiration' => $expiration); + $store = serialize(array('data' => $data, 'expiration' => $expiration)); if (is_null($expiration)) { return $this->redis->set($this->makeKeyString($key), $store); }