Zend Framework  3.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MemcachedResourceManager Class Reference

This is a resource manager for memcached. More...

Public Member Functions

 getServers ($id)
 Get servers.
 
 hasResource ($id)
 Check if a resource exists.
 
 getResource ($id)
 Gets a memcached resource.
 
 setResource ($id, $resource)
 Set a resource.
 
 removeResource ($id)
 Remove a resource.
 
 setPersistentId ($id, $persistentId)
 Set the persistent id.
 
 getPersistentId ($id)
 Get the persistent id.
 
 setLibOptions ($id, array $libOptions)
 Set Libmemcached options.
 
 getLibOptions ($id)
 Get Libmemcached options.
 
 setLibOption ($id, $key, $value)
 Set one Libmemcached option.
 
 getLibOption ($id, $key)
 Get one Libmemcached option.
 
 setServers ($id, $servers)
 Set servers.
 
 addServers ($id, $servers)
 Add servers.
 
 addServer ($id, $server)
 Add one server.
 

Protected Member Functions

 normalizeServer (&$server)
 Normalize one server into the following format: array('host' => <host>, 'port' => <port>, 'weight' => <weight>)
 
 normalizePersistentId (&$persistentId)
 Normalize the persistent id.
 
 normalizeLibOptions (&$libOptions)
 Normalize libmemcached options.
 
 normalizeLibOptionKey (&$key)
 Convert option name into it's constant value.
 
 normalizeServers (&$servers)
 Normalize a list of servers into the following format: array(array('host' => <host>, 'port' => <port>, 'weight' => <weight>)[, ...])
 
 compareServers (array $serverA, array $serverB)
 Compare 2 normalized server arrays (Compares only the host and the port)
 

Protected Attributes

 $resources = []
 

Detailed Description

This is a resource manager for memcached.

Member Function Documentation

addServer (   $id,
  $server 
)

Add one server.

Parameters
string$id
string | array$server
Returns
MemcachedResourceManager
addServers (   $id,
  $servers 
)

Add servers.

Parameters
string$id
string | array$servers
Returns
MemcachedResourceManager
compareServers ( array  $serverA,
array  $serverB 
)
protected

Compare 2 normalized server arrays (Compares only the host and the port)

Parameters
array$serverA
array$serverB
Returns
int
getLibOption (   $id,
  $key 
)

Get one Libmemcached option.

Parameters
string$id
string | int$key
Returns
mixed
Exceptions
Exception\RuntimeException
getLibOptions (   $id)

Get Libmemcached options.

Parameters
string$id
Returns
array
Exceptions
Exception\RuntimeException
getPersistentId (   $id)

Get the persistent id.

Parameters
string$id
Returns
string
Exceptions
Exception\RuntimeException
getResource (   $id)

Gets a memcached resource.

Parameters
string$id
Returns
MemcachedResource
Exceptions
Exception\RuntimeException
getServers (   $id)

Get servers.

Parameters
string$id
Exceptions
Exception\RuntimeException
Returns
array array('host' => <host>, 'port' => <port>, 'weight' => <weight>)
hasResource (   $id)

Check if a resource exists.

Parameters
string$id
Returns
bool
normalizeLibOptionKey ( $key)
protected

Convert option name into it's constant value.

Parameters
string | int$key
Exceptions
Exception\InvalidArgumentException
normalizeLibOptions ( $libOptions)
protected

Normalize libmemcached options.

Parameters
array | Traversable$libOptions
Exceptions
Exception\InvalidArgumentException
normalizePersistentId ( $persistentId)
protected

Normalize the persistent id.

Parameters
string$persistentId
normalizeServer ( $server)
protected

Normalize one server into the following format: array('host' => <host>, 'port' => <port>, 'weight' => <weight>)

Parameters
string | array&$server
Exceptions
Exception\InvalidArgumentException
normalizeServers ( $servers)
protected

Normalize a list of servers into the following format: array(array('host' => <host>, 'port' => <port>, 'weight' => <weight>)[, ...])

Parameters
string | array$servers
removeResource (   $id)

Remove a resource.

Parameters
string$id
Returns
MemcachedResourceManager Fluent interface
setLibOption (   $id,
  $key,
  $value 
)

Set one Libmemcached option.

Parameters
string$id
string | int$key
mixed$value
Returns
MemcachedResourceManager Fluent interface
setLibOptions (   $id,
array  $libOptions 
)

Set Libmemcached options.

Parameters
string$id
array$libOptions
Returns
MemcachedResourceManager Fluent interface
setPersistentId (   $id,
  $persistentId 
)

Set the persistent id.

Parameters
string$id
string$persistentId
Returns
MemcachedResourceManager Fluent interface
Exceptions
Exception\RuntimeException
setResource (   $id,
  $resource 
)

Set a resource.

Parameters
string$id
array | Traversable | MemcachedResource$resource
Returns
MemcachedResourceManager Fluent interface
setServers (   $id,
  $servers 
)

Set servers.

$servers can be an array list or a comma separated list of servers. One server in the list can be descripted as follows:

  • URI: [tcp://]<host>[:<port>][?weight=<weight>]
  • Assoc: array('host' => <host>[, 'port' => <port>][, 'weight' => <weight>])
  • List: array(<host>[, <port>][, <weight>])
Parameters
string$id
string | array$servers
Returns
MemcachedResourceManager

Member Data Documentation

$resources = []
protected