|
| __construct ($redis=null) |
| Initialize the Redis data store. More...
|
|
| __destruct () |
| Deconstruct the Redis data store. More...
|
|
| get ($type, $key) |
| Retrieve a value from the data store. More...
|
|
| set ($type, $key, $value, $expire=null) |
| Save a value in the data store. More...
|
|
| delete ($type, $key) |
| Delete an entry from the data store. More...
|
|
| get ($type, $key) |
| Retrieve a value from the data store. More...
|
|
| set ($type, $key, $value, $expire=null) |
| Save a value to the data store. More...
|
|
| delete ($type, $key) |
| Delete a value from the data store. More...
|
|
Definition at line 13 of file Redis.php.
◆ __construct()
SimpleSAML\Store\Redis::__construct |
( |
|
$redis = null | ) |
|
Initialize the Redis data store.
Definition at line 20 of file Redis.php.
21 {
22 assert(
$redis ===
null || is_subclass_of(
$redis,
'Predis\\Client'));
23
24 if (!class_exists('\Predis\Client')) {
25 throw new \SimpleSAML\Error\CriticalConfigurationError('predis/predis is not available.');
26 }
27
29 $config = Configuration::getInstance();
30
31 $host =
$config->getString(
'store.redis.host',
'localhost');
32 $port =
$config->getInteger(
'store.redis.port', 6379);
33 $prefix =
$config->getString(
'store.redis.prefix',
'SimpleSAMLphp');
34
35 $redis = new \Predis\Client(
36 array(
37 'scheme' => 'tcp',
38 'host' => $host,
39 'port' => $port,
40 ),
41 array(
42 'prefix' => $prefix,
43 )
44 );
45 }
46
48 }
References $config, and SimpleSAML\Store\Redis\$redis.
◆ __destruct()
SimpleSAML\Store\Redis::__destruct |
( |
| ) |
|
Deconstruct the Redis data store.
Definition at line 53 of file Redis.php.
54 {
55 if (method_exists($this->redis, 'disconnect')) {
56 $this->redis->disconnect();
57 }
58 }
◆ delete()
SimpleSAML\Store\Redis::delete |
( |
|
$type, |
|
|
|
$key |
|
) |
| |
Delete an entry from the data store.
- Parameters
-
string | $type | The type of the data |
string | $key | The key to delete. |
Reimplemented from SimpleSAML\Store.
Definition at line 112 of file Redis.php.
113 {
114 assert(is_string(
$type));
115 assert(is_string(
$key));
116
117 $this->redis->del("{$type}.{$key}");
118 }
References $key, and $type.
◆ get()
SimpleSAML\Store\Redis::get |
( |
|
$type, |
|
|
|
$key |
|
) |
| |
Retrieve a value from the data store.
- Parameters
-
string | $type | The type of the data. |
string | $key | The key to retrieve. |
- Returns
- mixed|null The value associated with that key, or null if there's no such key.
Reimplemented from SimpleSAML\Store.
Definition at line 68 of file Redis.php.
69 {
70 assert(is_string(
$type));
71 assert(is_string(
$key));
72
73 $result = $this->redis->get(
"{$type}.{$key}");
74
76 return null;
77 }
78
80 }
References $key, $result, and $type.
◆ set()
SimpleSAML\Store\Redis::set |
( |
|
$type, |
|
|
|
$key, |
|
|
|
$value, |
|
|
|
$expire = null |
|
) |
| |
Save a value in the data store.
- Parameters
-
string | $type | The type of the data. |
string | $key | The key to insert. |
mixed | $value | The value itself. |
int | null | $expire | The expiration time (unix timestamp), or null if it never expires. |
Reimplemented from SimpleSAML\Store.
Definition at line 90 of file Redis.php.
91 {
92 assert(is_string(
$type));
93 assert(is_string(
$key));
95
96 $serialized = serialize($value);
97
99 $this->redis->set("{$type}.{$key}", $serialized);
100 } else {
101
102 $this->redis->setex(
"{$type}.{$key}",
$expire - time(), $serialized);
103 }
104 }
References $expire, $key, and $type.
◆ $redis
SimpleSAML\Store\Redis::$redis |
The documentation for this class was generated from the following file:
- libs/composer/vendor/simplesamlphp/simplesamlphp/lib/SimpleSAML/Store/Redis.php