Skip to content

Commit ad8e999

Browse files
author
Jacob Christiansen
committed
Added default expiration time on all keys
1 parent 62aaef6 commit ad8e999

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/Store/Redis.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ protected function __construct()
66
$config = SimpleSAML_Configuration::getConfig('module_redis.php');
77
$host = $config->getString('host', 'localhost');
88
$this->redis = new Predis\Client($host);
9+
$this->lifeTime = $globalConfig->getInteger('session.duration', 28800); // Default 8 hours
910
}
1011

1112
/**
@@ -26,6 +27,9 @@ public function get($type, $key)
2627
/**
2728
* Save a value to Redis
2829
*
30+
* If no expiration time is given, then the expiration time is set to the
31+
* session duration.
32+
*
2933
* @param string $type The datatype
3034
* @param string $key The key
3135
* @param mixed $value The value
@@ -36,9 +40,10 @@ public function set($type, $key, $value, $expire = null)
3640
$redisKey = "simpleSAMLphp.$type.$key";
3741
$this->redis->set($redisKey, serialize($value));
3842

39-
if (!is_null($expire)) {
40-
$this->redis->expire($redisKey, $expire);
43+
if (is_null($expire)) {
44+
$expire = $this->lifeTime;
4145
}
46+
$this->redis->expire($redisKey, $expire);
4247
}
4348

4449
/**

0 commit comments

Comments
 (0)