Memcached caching backend.

Requires the memcache PECL extension to work, uses persistent connections.

Configuration options:

  • string host The host to connect to, defaults to localhost.
  • int port The port to connect to, defaults to the default port 11211.

Important notes:

  • This script does not synchronize multiple read/write accesses to the cache in the sense of a transaction.
  • This subclass will override the automatic serialization setting you made, as the memcache extension does this automatically.
  • Since this is about performance, (and memcached doesn't allow it in any other way), the get and exist calls are merged. Get will return false in case that the required key was not found. This effectively means that you cannot store "false" as a value.
  • The class will automatically add the name of the cache instance to the cache keys.
package midcom.services
see \global\http://www.php.net/manual/en/ref.memcache.php

 Methods

__construct ()

We use persistant connections, so we let midcom assume the read/write connection is always open

_close ()

This method is unused as we use persistant connections, letting memcached take care about synchronization.

_exists ($key)

Exists maps to the getter function, as memcached does not support exists checks.

Parameters

$key

_get ($key)

Parameters

$key

_on_initialize ()

This handler completes the configuration.

_open ($write)

This method is unused as we use persistant connections, letting memcached take care about synchronization.

Parameters

$write

_put ($key, $data, $timeout)

Parameters

$key

$data

$timeout

_remove ($key)

Parameters

$key

_remove_all ()

 Properties

 

mixed $_abort_on_fail

Whether to abort the request if connection to memcached fails
 

mixed $memcache_operational

Whether memcached is working
 

string $_host

The IP to connect to.
 

int $_port

The Port to connect to.
 

\Memcache $memcache

The Memcache interface object.