22 assert(
$redis === null || is_subclass_of(
$redis,
'Predis\\Client'));
24 if (!class_exists(
'\Predis\Client')) {
25 throw new \SimpleSAML\Error\CriticalConfigurationError(
'predis/predis is not available.');
29 $config = Configuration::getInstance();
31 $host =
$config->getString(
'store.redis.host',
'localhost');
32 $port =
$config->getInteger(
'store.redis.port', 6379);
33 $prefix =
$config->getString(
'store.redis.prefix',
'SimpleSAMLphp');
35 $redis = new \Predis\Client(
55 if (method_exists($this->redis,
'disconnect')) {
56 $this->redis->disconnect();
70 assert(is_string(
$type));
71 assert(is_string(
$key));
73 $result = $this->redis->get(
"{$type}.{$key}");
92 assert(is_string(
$type));
93 assert(is_string($key));
94 assert($expire === null || (is_int($expire) && $expire > 2592000));
96 $serialized = serialize($value);
98 if ($expire === null) {
99 $this->redis->set(
"{$type}.{$key}", $serialized);
102 $this->redis->setex(
"{$type}.{$key}", $expire - time(), $serialized);
114 assert(is_string(
$type));
115 assert(is_string($key));
117 $this->redis->del(
"{$type}.{$key}");
__destruct()
Deconstruct the Redis data store.
__construct($redis=null)
Initialize the Redis data store.