Skip to content

Commit a10b765

Browse files
committed
leave expiration handling to Redis and make use of the EXAT option, fixes #433 and #422
1 parent 64a8134 commit a10b765

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

src/Stash/Driver/Redis.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,20 +198,11 @@ public function getData($key)
198198
*/
199199
public function storeData($key, $data, $expiration)
200200
{
201-
$store = serialize(array('data' => $data, 'expiration' => $expiration));
201+
$store = array('data' => $data, 'expiration' => $expiration);
202202
if (is_null($expiration)) {
203203
return $this->redis->set($this->makeKeyString($key), $store);
204-
} else {
205-
$ttl = $expiration - time();
206-
207-
// Prevent us from even passing a negative ttl'd item to redis,
208-
// since it will just round up to zero and cache forever.
209-
if ($ttl < 1) {
210-
return true;
211-
}
212-
213-
return $this->redis->setex($this->makeKeyString($key), $ttl, $store);
214204
}
205+
return $this->redis->set($this->makeKeyString($key), $store, array('EXAT' => $expiration));
215206
}
216207

217208
/**

0 commit comments

Comments
 (0)