Follow me on twitter…

Instance manager

There can be different components (cache, sessions and etc) in you application, which may need their own Rediska instance with specific options (namespace, servers and etc).

Manager class is designed to store these Rediska instances. Manager can also store an array of Rediska options and Rediska instance will be created on a first request (lazy-loaded).


// Create 'default' instance
$rediska = new Rediska();

// Get 'default' instance from manager
$rediska = Rediska_Manager::get();
print $rediska->getName(); #=> default

// Create 'cache' instance for example
$rediska = new Rediska(array('name' => 'cache', 'namespace' => 'Cache_'));

// Get 'cache' instance from manager
$rediska = Rediska_Manager::get('cache');
print $rediska->getName(); #=> cache

// Add 'sessions' instance though options
Rediska_Manager::add(array('name' => 'sessions', 'namespace' => 'Sessions_'));

// Object created when it needed
$rediska = Rediska_Manager::get('sessions');
print $rediska->getName(); #=> sessions


See all Rediska_Manager methods.


Fork me on GitHub