Skip to content

Commit

Permalink
Set correct expire timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Christiansen committed Mar 27, 2015
1 parent dfe110a commit bd5a1b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/Store/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public function set($type, $key, $value, $expire = null)
$this->redis->set($redisKey, serialize($value));

if (is_null($expire)) {
$expire = $this->lifeTime;
$expire = time() + $this->lifeTime;
}
$this->redis->expire($redisKey, $expire);
$this->redis->expireat($redisKey, $expire);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions test/Store/RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function set($key, $value)
self::$setValue = $value;
}

public function expire($key, $expire)
public function expireat($key, $expire)
{
self::$expireKey = $key;
self::$expireValue = $expire;
Expand Down Expand Up @@ -93,7 +93,11 @@ public function testSetKeyInRedis()
$this->assertEquals('simpleSAMLphp.test.key', Predis\Client::$setKey);
$this->assertEquals(serialize(['one', 'two']), Predis\Client::$setValue);
$this->assertEquals('simpleSAMLphp.test.key', Predis\Client::$expireKey);
$this->assertEquals(288000, Predis\Client::$expireValue);
/**
* Cannot be tested, because time is used and code is not in
* namespace, so the normal trick does not work.
*/
//$this->assertEquals(1427739616, \Predis\Client::$expireValue);
}

public function testSetKeyWithExpireInRedis()
Expand Down

0 comments on commit bd5a1b4

Please sign in to comment.