\cge_datastore

This class implements a simple key/value store utilizing the database intended for storing small amounts of temporary data that must survive both the request, and the session but can have a limited lifetime.

Each entry can have up to 3 cascading keys. It features automatic deletion of expired keys.

Summary

Methods
Properties
Constants
__construct()
set_expiry()
remove_expired()
erase()
store()
get()
listall()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(integer  $expiry = 3600) 

Construct a new datastore object.

Parameters

integer $expiry

The amount of time until values stored with this object will expire. Minimum of 30 seconds.

set_expiry()

set_expiry(integer  $num) 

Adjust the expiry of data stored with this object.

Parameters

integer $num

The amount of time until values stored with this object will expire. Minimum of 30 seconds.

remove_expired()

remove_expired() 

Remove all expired entries from the database.

This method will return all expired entries from the database, regardless of whether they were stored with this instance or not.

erase()

erase(string  $key1, string  $key2 = '', string  $key3 = '', string  $key4 = '') 

Erase the specified data from the database

Parameters

string $key1
string $key2
  • An optional additional key that is combined with key1
string $key3
  • An optional additional key that is combined with key1 and key2
string $key4
  • An optional additional key that is combined with key1, key2, and key3

store()

store(mixed  $data, string  $key1, string  $key2 = '', string  $key3 = '', string  $key4 = '') 

Store the specified data into the database

Parameters

mixed $data
string $key1
string $key2
  • An optional additional key that is combined with key1
string $key3
  • An optional additional key that is combined with key1 and key2
string $key4
  • An optional additional key that is combined with key1, key2, and key3

get()

get(string  $key1, string  $key2 = '', string  $key3 = '', string  $key4 = '') : mixed

Retrieve the specified data from the database

Parameters

string $key1
string $key2
  • An optional additional key that is combined with key1
string $key3
  • An optional additional key that is combined with key1 and key2
string $key4
  • An optional additional key that is combined with key1, key2, and key3

Returns

mixed

listall()

listall(string  $key1, string  $key2 = null, string  $key3 = null) : array

List all of the data matching the specified keys.

The fiewer keys specified should result in more matches.

Parameters

string $key1
string $key2
  • An optional additional key that is combined with key1
string $key3
  • An optional additional key that is combined with key1 and key2

Returns

array