App Engine PHP SDK  v1 rev.445
The PHP runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Memcached Class Reference

Public Member Functions

 deleteMulti ($keys, $time=0)
 
 __construct ($persistent_id=null)
 
 add ($key, $value, $expiration=0)
 
 addByKey ($server_key, $key, $value, $expiration=0)
 
 addServer ($host, $port, $weight=0)
 
 addServers ($servers)
 
 append ($key, $value)
 
 appendByKey (string $server_key, string $key, string $value)
 
 cas ($cas_token, $key, $value, $expiration=0)
 
 casByKey ($cas_token, $server_key, $key, $value, $expiration=0)
 
 decrement ($key, $offset=1, $initial_value=0, $expiration=0)
 
 decrementByKey ($server_key, $key, $offset=1, $initial_value=0, $expiration=0)
 
 delete ($key, $time=0)
 
 deleteByKey ($server_key, $key, $time=0)
 
 deleteMulti ($keys, $time=0)
 
 deleteMultiByKey ($server_key, $keys, $time=0)
 
 fetch ()
 
 fetchAll ()
 
 flush ($delay=0)
 
 get ($key, $cache_cb=null, &$cas_token=null)
 
 getAllKeys ()
 
 getByKey ($server_key, $key, $cache_cb, &$cas_token)
 
 getDelayed ($keys, $with_cas=false, $value_cb=null)
 
 getDelayedByKey ($server_key, $keys, $with_cas=false, $value_cb=null)
 
 getMulti ($keys, &$cas_tokens=null, $flags=0)
 
 getMultiByKey ($server_key, $keys, $with_cas=false, $value_cb=null)
 
 getOption ($option)
 
 getResultCode ()
 
 getResultMessage ()
 
 getServerByKey ($server_key)
 
 getServerList ()
 
 getStats ()
 
 getVersion ()
 
 increment ($key, $offset=1, $initial_value=0, $expiry=0)
 
 incrementByKey ($server_key, $key, $offset=1, $initial_value=0, $expiry=0)
 
 isPersistent ()
 
 isPristine ()
 
 prepend ($key, $value)
 
 prependByKey ($server_key, $key, $value)
 
 quit ()
 
 replace ($key, $value, $expiration=0)
 
 replaceByKey ($server_key, $key, $value, $expiration=0)
 
 resetServerList ()
 
 set ($key, $value, $expiration=0)
 
 setByKey ($server_key, $key, $value, $expiration=0)
 
 setMulti ($items, $expiration=0)
 
 setMultiByKey ($server_key, $items, $expiration=0)
 
 setOption ($option, $value)
 
 setOptions ($options)
 
 setSaslAuthData ($username, $password)
 
 touch ($key, $expiration=0)
 
 touchByKey ($server_key, $key, $expiration=0)
 

Static Public Member Functions

static setMockMemcached ($mock)
 

Public Attributes

const OPT_PREFIX_KEY = 1
 
const OPT_COMPRESSION = 2
 
const OPT_HASH = 3
 
const OPT_DISTRIBUTION = 4
 
const OPT_BUFFER_WRITES = 5
 
const OPT_BINARY_PROTOCOL = 6
 
const OPT_NO_BLOCK = 7
 
const OPT_TCP_NODELAY = 8
 
const OPT_SOCKET_SEND_SIZE = 9
 
const OPT_SOCKET_RECV_SIZE = 10
 
const OPT_CONNECT_TIMEOUT = 11
 
const OPT_RETRY_TIMEOUT = 12
 
const OPT_SEND_TIMEOUT = 13
 
const OPT_RECV_TIMEOUT = 14
 
const OPT_POLL_TIMEOUT = 15
 
const OPT_CACHE_LOOKUPS = 16
 
const OPT_SERVER_FAILURE_LIMIT = 17
 
const OPT_SERIALIZER = 18
 
const HAVE_IGBINARY = 20
 
const HAVE_JSON = 21
 
const SERIALIZER_PHP = 100
 
const SERIALIZER_IGBINARY = 101
 
const SERIALIZER_JSON = 102
 
const HASH_DEFAULT = 200
 
const HASH_MD5 = 201
 
const HASH_CRC = 202
 
const HASH_FNV1_64 = 203
 
const HASH_FNV1A_64 = 204
 
const HASH_FNV1_32 = 205
 
const HASH_FNV1A_32 = 206
 
const HASH_HSIEH = 207
 
const HASH_MURMUR = 208
 
const DISTRIBUTION_MODULA = 300
 
const DISTRIBUTION_CONSISTENT = 301
 
const OPT_LIBKETAMA_COMPATIBLE = 302
 
const GET_PRESERVE_ORDER = 10
 
const RES_SUCCESS = 0
 
const RES_FAILURE = 1
 
const RES_HOST_LOOKUP_FAILURE = 2
 
const RES_UNKNOWN_READ_FAILURE = 7
 
const RES_PROTOCOL_ERROR = 8
 
const RES_CLIENT_ERROR = 9
 
const RES_SERVER_ERROR = 10
 
const RES_WRITE_FAILURE = 5
 
const RES_DATA_EXISTS = 12
 
const RES_NOTSTORED = 14
 
const RES_NOTFOUND = 16
 
const RES_PARTIAL_READ = 18
 
const RES_SOME_ERRORS = 19
 
const RES_NO_SERVERS = 20
 
const RES_END = 21
 
const RES_ERRNO = 26
 
const RES_BUFFERED = 32
 
const RES_TIMEOUT = 31
 
const RES_BAD_KEY_PROVIDED = 33
 
const RES_CONNECTION_SOCKET_CREATE_FAILURE = 11
 
const RES_PAYLOAD_FAILURE = -1001
 

Static Public Attributes

static $mock_memcached = null
 

Member Function Documentation

Memcached::add (   $key,
  $value,
  $expiration = 0 
)

add is similar to set(), but the operation fails if the key already exists on the server.

See also
Memcached::set()
Parameters
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
bool true on success, false on failure.
Memcached::addByKey (   $server_key,
  $key,
  $value,
  $expiration = 0 
)

Memcached::addByKey() is functionally equivalent to Memcached::add(), except that the free-form server_key can be used to map the key to a specific server. This is useful if you need to keep a bunch of related keys on a certain server.

See also
Memcached::add()
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
bool true on success, false on failure.
Memcached::addServer (   $host,
  $port,
  $weight = 0 
)

This function is present only for compatibility and does nothing.

Memcached::addServers (   $servers)

This function is present only for compatibility and does nothing.

Memcached::append (   $key,
  $value 
)

Memcached::append() appends the given value string to the value of an existing item. The reason that value is forced to be a string is that appending mixed types is not well-defined.

Parameters
string$keyThe key under which to append the value.
string$valueThe value to append
Returns
bool Returns true on success or false on failure.
Memcached::appendByKey ( string  $server_key,
string  $key,
string  $value 
)
See also
Memcached::append().
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to append the value.
string$valueThe value to append
Returns
bool Returns true on success or false on failure.
Memcached::cas (   $cas_token,
  $key,
  $value,
  $expiration = 0 
)

Performs a set and check operation, so that the item will be stored only if no other client has updated it since it was last fetched by this client.

Parameters
mixed$cas_tokenUnique memcached assigned value.
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
bool True on success, or false on failure.
Memcached::casByKey (   $cas_token,
  $server_key,
  $key,
  $value,
  $expiration = 0 
)
See also
Memcached::cas().
Parameters
mixed$cas_tokenUnique memcached assigned value.
string$server_keyIgnored.
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
bool True on success, or false on failure.
Memcached::decrement (   $key,
  $offset = 1,
  $initial_value = 0,
  $expiration = 0 
)

Decrements a numeric item's value by $offset.

Parameters
string$keyThe key under which to store the value.
int$offsetThe amount by which to decrement the item's value.
int$initial_valueThe value to set the item to if it does not currently exist.
int$expirationThe expiration time, defaults to 0.
Returns
bool True on success, or false on failure.
Memcached::decrementByKey (   $server_key,
  $key,
  $offset = 1,
  $initial_value = 0,
  $expiration = 0 
)
See also
Memcached::decrement().
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
int$offsetThe amount by which to decrement the item's value.
int$initial_valueThe value to set the item to if it does not currently exist.
int$expirationThe expiration time, defaults to 0.
Returns
bool True on success, or false on failure.
Memcached::delete (   $key,
  $time = 0 
)

deletes the $key from the server.

Parameters
string$keyThe key to delete from the server.
int$timeThe time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.
Returns
bool true on success or false on failure.
Memcached::deleteByKey (   $server_key,
  $key,
  $time = 0 
)
See also
Memcached::delete().
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key to delete from the server.
int$timeThe time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.
Returns
bool true on success or false on failure.
Memcached::deleteMulti (   $keys,
  $time = 0 
)

deletes an array of $keys from the server.

Parameters
array$keysThe keys to delete from the server.
int$timeThe time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.
Returns
bool true on success or false on failure.
Memcached::deleteMultiByKey (   $server_key,
  $keys,
  $time = 0 
)
See also
Memcache::deleteMulti().
Parameters
string$server_keyThis parameter is ignored.
array$keysThe keys to delete from the server.
int$timeThe time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.
Returns
bool true on success or false on failure.
Memcached::fetch ( )

fetch retrieves the next result from the last getDelayed() request.

Note that currently getDelayed is a synchronous call.

Returns
The next result, or false if there are no more results.
Memcached::fetchAll ( )

Fetch all of the remaining results from the last getDelayed() request.

Note that currently getDelayed is a synchronous call.

Returns
array The remaining results, or false if there are no results.
Memcached::flush (   $delay = 0)

Invalidates all existing cache items immediately.

Parameters
int$delayThis parameter is ignored.
Returns
bool true on success, or false on failure.
Memcached::get (   $key,
  $cache_cb = null,
$cas_token = null 
)

Returns the item that was previously stored under the $key.

Parameters
string$keyThe key under which to store the value.
callable$cache_cbRead through caching callback.
mixed$cas_tokenThe variable to store the CAS token in. This value is opaque to the application.
Returns
the value stored in the cache of false if there was a failure.
Memcached::getAllKeys ( )

This function is present only for compatibility and does nothing.

Memcached::getByKey (   $server_key,
  $key,
  $cache_cb,
$cas_token 
)
See also
Memcache::get().
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
callable$cache_cbRead through caching callback.
mixed$cas_tokenThe variable to store the CAS token in. This value is opaque to the application.
Returns
the value stored in the cache of false if there was a failure.
Memcached::getDelayed (   $keys,
  $with_cas = false,
  $value_cb = null 
)

Issues a request to memcache for multiple items the keys of which are specified in the keys array. Currently this method executes synchronously.

Parameters
array$keysArray of keys to retrieve.
bool$with_casIf true, retrieve the CAS tokens for the keys.
callable$value_cbThe result callback.
Returns
bool true on success, or false on failure.
Memcached::getDelayedByKey (   $server_key,
  $keys,
  $with_cas = false,
  $value_cb = null 
)
See also
getDelayedByKey.
Parameters
string$server_keyThis parameter is ignored.
array$keysArray of keys to retrieve.
bool$with_casIf true, retrieve the CAS tokens for the keys.
callable$value_cbThe result callback.
Returns
bool true on success, or false on failure.
Memcached::getMulti (   $keys,
$cas_tokens = null,
  $flags = 0 
)

Similar to Memcached::get(), but instead of a single key item, it retrieves multiple items the keys of which are specified in the keys array.

See also
Memcached::get()
Parameters
array$keysArray of keys to retrieve.
array$cas_tokensThe variable to store the CAS tokens for found items.
int$flagsThe flags for the get operation.
Returns
array The array of found items for false on failure.
Memcached::getMultiByKey (   $server_key,
  $keys,
  $with_cas = false,
  $value_cb = null 
)
See also
Memcached::getMulti()
Parameters
string$server_keyThis parameter is ignored.
array$keysArray of keys to retrieve.
array$cas_tokensThe variable to store the CAS tokens for found items.
int$flagsThe flags for the get operation.
Returns
array The array of found items for false on failure.
Memcached::getOption (   $option)

Retrieve a Memcached option value.

int $option One of the Memcached::OPT_* constants.

Returns
mixed the value of the requested option, of false on error.
Memcached::getResultCode ( )

Returns one of the Memcached::RES_* constants that is the result of the last executed Memcached method.

Returns
int The result code of the last memcached operation.
Memcached::getResultMessage ( )

Return the message describing the result of the last operation.

Returns
string Message describing the result of the last operation.
Memcached::getServerByKey (   $server_key)

This function is present only for compatibility and does nothing.

Memcached::getServerList ( )

This function is present only for compatibility and does nothing.

Memcached::getStats ( )

This function is present only for compatibility and does nothing.

Memcached::getVersion ( )

This function is present only for compatibility and does nothing.

Memcached::increment (   $key,
  $offset = 1,
  $initial_value = 0,
  $expiry = 0 
)

Increments a numeric item's value by the specified offset. If the item's value is not numeric, and error will result.

Parameters
string$keyThe key of the item to increment
int$offsetThe amount by which to increment the item's value
int$initial_valueThe value to set the item to if it doesn't exist.
int$expiryThe expiry time to set on the item.
Returns
The new item's value on success or false on failure.
Memcached::incrementByKey (   $server_key,
  $key,
  $offset = 1,
  $initial_value = 0,
  $expiry = 0 
)
See also
Memcached::increment()
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key of the item to increment
int$offsetThe amount by which to increment the item's value
int$initial_valueThe value to set the item to if it doesn't exist.
int$expiryThe expiry time to set on the item.
Returns
The new item's value on success or false on failure.
Memcached::isPersistent ( )

This function is present only for compatibility and does nothing.

Memcached::isPristine ( )

This function is present only for compatibility and does nothing.

Memcached::prepend (   $key,
  $value 
)

Prepends the given value string to an existing item.

Parameters
string$keyThe key under which to store the value.
string$valueThe string to prepend.
Returns
true on success or false on failure.
Memcached::prependByKey (   $server_key,
  $key,
  $value 
)
See also
Memcached::prepend()
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
string$valueThe string to prepend.
Returns
true on success or false on failure.
Memcached::quit ( )

This function is present only for compatibility and does nothing.

Memcached::replace (   $key,
  $value,
  $expiration = 0 
)

Replace is similar to Memcache::set(), but the operation will fail if the key is not found on the server.

Parameters
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
true if the method succeeds, false on failure.
Memcached::replaceByKey (   $server_key,
  $key,
  $value,
  $expiration = 0 
)
See also
Memcached::replace()
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
true if the method succeeds, false on failure.
Memcached::resetServerList ( )

This function is present only for compatibility and does nothing.

Memcached::set (   $key,
  $value,
  $expiration = 0 
)

Stores the value on a memcache server under the specified key. The expiration parameters can be used to control when the value is considered expired.

Parameters
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
true if the method succeeds, false on failure.
Memcached::setByKey (   $server_key,
  $key,
  $value,
  $expiration = 0 
)
See also
Memcached::set()
Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to store the value.
mixed$valueThe value to store.
int$expirationThe expiration time, defaults to 0.
Returns
true if the method succeeds, false on failure.
Memcached::setMulti (   $items,
  $expiration = 0 
)

Is similar to Memcached::set(), but instead of a single key/value item, it works on multiple items specified in items.

See also
Memcached::set()
Parameters
array$itemsAn array of key value pairs to set.
int$expirationThe expiration time to set for the value.

returns bool true if the call succeeds, false otherwise.

Memcached::setMultiByKey (   $server_key,
  $items,
  $expiration = 0 
)
See also
Memcached::setMulti()
Parameters
string$server_keyThis parameter is ignored.
array$itemsAn array of key value pairs to set.
int$expirationThe expiration time to set for the value.
Returns
bool true if the call succeeds, false otherwise.
Memcached::setOption (   $option,
  $value 
)

This method sets the vaue of a memcached option.

Parameters
int$optionThe option to set.
mixed$valueThe value to set the option to.
Returns
bool true if the call succeeds, false otherwise.
Memcached::setOptions (   $options)

This is a varion of Memcached::setOption() that takes an array of options to be set.

Parameters
mixed$optionsAn associated array of options.
Returns
bool true if the call succeeds, false otherwise.
Memcached::setSaslAuthData (   $username,
  $password 
)

This function is present only for compatibility and does nothing.

Memcached::touch (   $key,
  $expiration = 0 
)

Sets a new expiration time on an item.

Parameters
string$keyThe key under which to append the value.
int$expirationThe expiration time, defaults to 0.
Returns
bool true on success or false on failure.
Memcached::touchByKey (   $server_key,
  $key,
  $expiration = 0 
)

Functionally equivalent to Memcached::touch().

Parameters
string$server_keyThis parameter is ignored.
string$keyThe key under which to append the value.
int$expirationThe expiration time, defaults to 0.
Returns
bool true on success or false on failure.

Member Data Documentation

const Memcached::OPT_PREFIX_KEY = 1

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