ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SimpleSAML\Store\Redis Class Reference
+ Inheritance diagram for SimpleSAML\Store\Redis:
+ Collaboration diagram for SimpleSAML\Store\Redis:

Public Member Functions

 __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...
 

Additional Inherited Members

- Static Public Member Functions inherited from SimpleSAML\Store
static getInstance ()
 Retrieve our singleton instance. More...
 

Detailed Description

Definition at line 13 of file Redis.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML\Store\Redis::__construct (   $redis = null)

Initialize the Redis data store.

Definition at line 18 of file Redis.php.

19 {
20 assert('is_null($redis) || is_subclass_of($redis, "Predis\\Client")');
21
22 if (!class_exists('\Predis\Client')) {
23 throw new \SimpleSAML\Error\CriticalConfigurationError('predis/predis is not available.');
24 }
25
26 if (is_null($redis)) {
27 $config = Configuration::getInstance();
28
29 $host = $config->getString('store.redis.host', 'localhost');
30 $port = $config->getInteger('store.redis.port', 6379);
31 $prefix = $config->getString('store.redis.prefix', 'SimpleSAMLphp');
32
33 $redis = new \Predis\Client(
34 array(
35 'scheme' => 'tcp',
36 'host' => $host,
37 'port' => $port,
38 ),
39 array(
40 'prefix' => $prefix,
41 )
42 );
43 }
44
45 $this->redis = $redis;
46 }

References $config.

◆ __destruct()

SimpleSAML\Store\Redis::__destruct ( )

Deconstruct the Redis data store.

Definition at line 51 of file Redis.php.

52 {
53 if (method_exists($this->redis, 'disconnect')) {
54 $this->redis->disconnect();
55 }
56 }

Member Function Documentation

◆ delete()

SimpleSAML\Store\Redis::delete (   $type,
  $key 
)

Delete an entry from the data store.

Parameters
string$typeThe type of the data
string$keyThe key to delete.

Reimplemented from SimpleSAML\Store.

Definition at line 109 of file Redis.php.

110 {
111 assert('is_string($type)');
112 assert('is_string($key)');
113
114 $this->redis->del("{$type}.{$key}");
115 }

◆ get()

SimpleSAML\Store\Redis::get (   $type,
  $key 
)

Retrieve a value from the data store.

Parameters
string$typeThe type of the data.
string$keyThe 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 66 of file Redis.php.

67 {
68 assert('is_string($type)');
69 assert('is_string($key)');
70
71 $result = $this->redis->get("{$type}.{$key}");
72
73 if ($result === false || $result === null) {
74 return null;
75 }
76
77 return unserialize($result);
78 }
$result

References $result.

◆ set()

SimpleSAML\Store\Redis::set (   $type,
  $key,
  $value,
  $expire = null 
)

Save a value in the data store.

Parameters
string$typeThe type of the data.
string$keyThe key to insert.
mixed$valueThe value itself.
int | null$expireThe expiration time (unix timestamp), or null if it never expires.

Reimplemented from SimpleSAML\Store.

Definition at line 88 of file Redis.php.

89 {
90 assert('is_string($type)');
91 assert('is_string($key)');
92 assert('is_null($expire) || (is_int($expire) && $expire > 2592000)');
93
94 $serialized = serialize($value);
95
96 if (is_null($expire)) {
97 $this->redis->set("{$type}.{$key}", $serialized);
98 } else {
99 $this->redis->setex("{$type}.{$key}", $expire, $serialized);
100 }
101 }
$expire
Definition: saml2-acs.php:140

References $expire.


The documentation for this class was generated from the following file: