ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_riak_Store_Store Class Reference
+ Inheritance diagram for sspmod_riak_Store_Store:
+ Collaboration diagram for sspmod_riak_Store_Store:

Public Member Functions

 get ($type, $key)
 Retrieve a value from the datastore. More...
 
 set ($type, $key, $value, $expire=null)
 Save a value to the datastore. More...
 
 delete ($type, $key)
 Delete a value from the datastore. More...
 
- Public Member Functions inherited from SimpleSAML\Store
 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...
 

Data Fields

 $client
 
 $bucket
 

Protected Member Functions

 __construct ()
 

Additional Inherited Members

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

Detailed Description

Definition at line 25 of file Store.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_riak_Store_Store::__construct ( )
protected

Definition at line 30 of file Store.php.

References $bucket, $config, $path, and SimpleSAML_Configuration\getConfig().

31  {
32  $config = SimpleSAML_Configuration::getConfig('module_riak.php');
33 
34  $path = $config->getString('path', 'riak-php-client/riak.php');
35  $host = $config->getString('host', 'localhost');
36  $port = $config->getString('port', 8098);
37  $bucket = $config->getString('bucket', 'simpleSAMLphp');
38 
39  require_once($path);
40  $this->client = new \RiakClient($host, $port);
41  $this->bucket = $this->client->bucket($bucket);
42  }
$path
Definition: aliased.php:25
$config
Definition: bootstrap.php:15
static getConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

sspmod_riak_Store_Store::delete (   $type,
  $key 
)

Delete a value from the datastore.

Parameters
string$typeThe datatype.
string$keyThe key.

Definition at line 99 of file Store.php.

References $type.

100  {
101  assert(is_string($type));
102  assert(is_string($key));
103 
104  $v = $this->bucket->getBinary("$type.$key");
105  if (!$v->exists()) {
106  return;
107  }
108 
109  $v->delete();
110  }
$type
$key
Definition: croninfo.php:18

◆ get()

sspmod_riak_Store_Store::get (   $type,
  $key 
)

Retrieve a value from the datastore.

Parameters
string$typeThe datatype.
string$keyThe key.
Returns
mixed|NULL The value.

Definition at line 51 of file Store.php.

References $key, and $type.

52  {
53  assert(is_string($type));
54  assert(is_string($key));
55 
56  $v = $this->bucket->getBinary("$type.$key");
57  if (!$v->exists()) {
58  return null;
59  }
60 
61  $expires = $v->getIndex('Expires', 'int');
62  if (sizeof($expires) && (int)array_shift($expires) <= time()) {
63  $v->delete();
64  return null;
65  }
66 
67  return (unserialize($v->getData()));
68  }
$type
$key
Definition: croninfo.php:18

◆ set()

sspmod_riak_Store_Store::set (   $type,
  $key,
  $value,
  $expire = null 
)

Save a value to the datastore.

Parameters
string$typeThe datatype.
string$keyThe key.
mixed$valueThe value.
int | NULL$expireThe expiration time (unix timestamp), or NULL if it never expires.

Definition at line 79 of file Store.php.

References $type.

80  {
81  assert(is_string($type));
82  assert(is_string($key));
83  assert($expire === null || (is_int($expire) && $expire > 2592000));
84 
85  $v = $this->bucket->newBinary("$type.$key", serialize($value), 'application/php');
86  if (!is_null($expire)) {
87  $v->addIndex("Expires", "int", $expire);
88  }
89 
90  $v->store();
91  }
$expire
Definition: saml2-acs.php:140
$type
$key
Definition: croninfo.php:18

Field Documentation

◆ $bucket

sspmod_riak_Store_Store::$bucket

Definition at line 28 of file Store.php.

Referenced by __construct().

◆ $client

sspmod_riak_Store_Store::$client

Definition at line 27 of file Store.php.


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