Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



google/appengine/runtime/Memcached.php

Table of Contents
Copyright 2007 Google Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

\Memcached

Package: Default

Constants

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

Methods

method public __construct ( $persistent_id = null) : void

Parameters
Name Type Description
$persistent_id
method public add (string $key, mixed $value, int $expiration = 0) : bool

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

Parameters
Name Type Description
$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool true on success, false on failure.
Details
See
\Memcached::set()
method public addByKey (string $server_key, string $key, mixed $value, int $expiration = 0) : bool

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.

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool true on success, false on failure.
Details
See
\Memcached::add()
method public addServer ( $host,  $port,  $weight = 0) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
$port
$weight
method public addServers ( $servers) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$servers
method public append (string $key, string $value) : void

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
Name Type Description
$key string

The key under which to append the value.

$value string

The value to append

Details
Result
bool Returns true on success or false on failure.
method public appendByKey (string $server_key, string $key, string $value) : void

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to append the value.

$value string

The value to append

Details
Result
bool Returns true on success or false on failure.
See
\Memcached::append().
method public cas (mixed $cas_token, string $key, mixed $value, int $expiration = 0) : bool

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
Name Type Description
$cas_token mixed

Unique memcached assigned value.

$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool True on success, or false on failure.
method public casByKey (mixed $cas_token, string $server_key, string $key, mixed $value, int $expiration = 0) : bool

Parameters
Name Type Description
$cas_token mixed

Unique memcached assigned value.

$server_key string

Ignored.

$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool True on success, or false on failure.
Details
See
\Memcached::cas().
method public decrement (string $key, int $offset = 1, int $initial_value = 0, int $expiration = 0) : bool

Decrements a numeric item's value by $offset.

Parameters
Name Type Description
$key string

The key under which to store the value.

$offset int

The amount by which to decrement the item's value.

$initial_value int

The value to set the item to if it does not currently exist.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool True on success, or false on failure.
method public decrementByKey (string $server_key, string $key, int $offset = 1, int $initial_value = 0, int $expiration = 0) : bool

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$offset int

The amount by which to decrement the item's value.

$initial_value int

The value to set the item to if it does not currently exist.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool True on success, or false on failure.
Details
See
\Memcached::decrement().
method public delete (string $key, int $time = 0) : bool

deletes the $key from the server.

Parameters
Name Type Description
$key string

The key to delete from the server.

$time int

The time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.

Returns
Type Description
bool true on success or false on failure.
method public deleteByKey (string $server_key, string $key, int $time = 0) : bool

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key to delete from the server.

$time int

The time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.

Returns
Type Description
bool true on success or false on failure.
Details
See
\Memcached::delete().
method public deleteMulti (array $keys, int $time = 0) : bool

deletes an array of $keys from the server.

Parameters
Name Type Description
$keys array

The keys to delete from the server.

$time int

The time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.

Returns
Type Description
bool true on success or false on failure.
method public deleteMultiByKey (string $server_key, array $keys, int $time = 0) : bool

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$keys array

The keys to delete from the server.

$time int

The time parameter is the amount of time in seconds the client wishes the server to refuse add and replace commands for this key.

Returns
Type Description
bool true on success or false on failure.
Details
See
\Memcache::deleteMulti().
method public fetch () : \The

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

Note that currently getDelayed is a synchronous call.

Returns
Type Description
\The next result, or false if there are no more results.
method public fetchAll () : array

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

Note that currently getDelayed is a synchronous call.

Returns
Type Description
array The remaining results, or false if there are no results.
method public flush (int $delay = 0) : bool

Invalidates all existing cache items immediately.

Parameters
Name Type Description
$delay int

This parameter is ignored.

Returns
Type Description
bool true on success, or false on failure.
method public get (string $key, callable $cache_cb = null, mixed $cas_token = null) : \the

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

Parameters
Name Type Description
$key string

The key under which to store the value.

$cache_cb callable

Read through caching callback.

$cas_token mixed

The variable to store the CAS token in. This value is opaque to the application.

Returns
Type Description
\the value stored in the cache of false if there was a failure.
method public getAllKeys () : void

This function is present only for compatibility and does nothing.

method public getByKey (string $server_key, string $key, callable $cache_cb, mixed $cas_token) : \the

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$cache_cb callable

Read through caching callback.

$cas_token mixed

The variable to store the CAS token in. This value is opaque to the application.

Returns
Type Description
\the value stored in the cache of false if there was a failure.
Details
See
\Memcache::get().
method public getDelayed (array $keys, bool $with_cas = false, callable $value_cb = null) : bool

Issues a request to memcache for multiple items the keys of which are specified in the keys array.

Currently this method executes synchronously.

Parameters
Name Type Description
$keys array

Array of keys to retrieve.

$with_cas bool

If true, retrieve the CAS tokens for the keys.

$value_cb callable

The result callback.

Returns
Type Description
bool true on success, or false on failure.
method public getDelayedByKey (string $server_key, array $keys, bool $with_cas = false, callable $value_cb = null) : bool

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$keys array

Array of keys to retrieve.

$with_cas bool

If true, retrieve the CAS tokens for the keys.

$value_cb callable

The result callback.

Returns
Type Description
bool true on success, or false on failure.
Details
See
\getDelayedByKey.
method public getMulti (array $keys, array $cas_tokens = null, int $flags = 0) : array

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.

Parameters
Name Type Description
$keys array

Array of keys to retrieve.

$cas_tokens array

The variable to store the CAS tokens for found items.

$flags int

The flags for the get operation.

Returns
Type Description
array The array of found items for false on failure.
Details
See
\Memcached::get()
method public getMultiByKey (string $server_key, array $keys,  $with_cas = false,  $value_cb = null) : array

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$keys array

Array of keys to retrieve.

$with_cas
$value_cb
Returns
Type Description
array The array of found items for false on failure.
Details
See
\Memcached::getMulti()
method public getOption ( $option) : mixed

Retrieve a Memcached option value.

Parameters
Name Type Description
$option
Returns
Type Description
mixed the value of the requested option, of false on error.
Details
Params
int $option One of the Memcached::OPT_* constants.
method public getResultCode () : int

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

Returns
Type Description
int The result code of the last memcached operation.
method public getResultMessage () : string

Return the message describing the result of the last operation.

Returns
Type Description
string Message describing the result of the last operation.
method public getServerByKey ( $server_key) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$server_key
method public getServerList () : void

This function is present only for compatibility and does nothing.

method public getStats () : void

This function is present only for compatibility and does nothing.

method public getVersion () : void

This function is present only for compatibility and does nothing.

method public increment (string $key, int $offset = 1, int $initial_value = 0, int $expiry = 0) : \The

Increments a numeric item's value by the specified offset.

If the item's value is not numeric, and error will result.

Parameters
Name Type Description
$key string

The key of the item to increment

$offset int

The amount by which to increment the item's value

$initial_value int

The value to set the item to if it doesn't exist.

$expiry int

The expiry time to set on the item.

Returns
Type Description
\The new item's value on success or false on failure.
method public incrementByKey (string $server_key, string $key, int $offset = 1, int $initial_value = 0, int $expiry = 0) : \The

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key of the item to increment

$offset int

The amount by which to increment the item's value

$initial_value int

The value to set the item to if it doesn't exist.

$expiry int

The expiry time to set on the item.

Returns
Type Description
\The new item's value on success or false on failure.
Details
See
\Memcached::increment()
method public isPersistent () : void

This function is present only for compatibility and does nothing.

method public isPristine () : void

This function is present only for compatibility and does nothing.

method public prepend (string $key, string $value) : true

Prepends the given value string to an existing item.

Parameters
Name Type Description
$key string

The key under which to store the value.

$value string

The string to prepend.

Returns
Type Description
true on success or false on failure.
method public prependByKey (string $server_key, string $key, string $value) : true

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$value string

The string to prepend.

Returns
Type Description
true on success or false on failure.
Details
See
\Memcached::prepend()
method public quit () : void

This function is present only for compatibility and does nothing.

method public replace (string $key, mixed $value, int $expiration = 0) : true

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

Parameters
Name Type Description
$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
true if the method succeeds, false on failure.
method public replaceByKey (string $server_key, string $key, mixed $value, int $expiration = 0) : true

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
true if the method succeeds, false on failure.
Details
See
\Memcached::replace()
method public resetServerList () : void

This function is present only for compatibility and does nothing.

method public set (string $key, mixed $value, int $expiration = 0) : true

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
Name Type Description
$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
true if the method succeeds, false on failure.
method public setByKey (string $server_key, string $key, mixed $value, int $expiration = 0) : true

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to store the value.

$value mixed

The value to store.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
true if the method succeeds, false on failure.
Details
See
\Memcached::set()
method public setMulti (array $items, int $expiration = 0) : void

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

Parameters
Name Type Description
$items array

An array of key value pairs to set.

$expiration int

The expiration time to set for the value. returns bool true if the call succeeds, false otherwise.

Details
See
\Memcached::set()
method public setMultiByKey (string $server_key, array $items, int $expiration = 0) : bool

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$items array

An array of key value pairs to set.

$expiration int

The expiration time to set for the value.

Returns
Type Description
bool true if the call succeeds, false otherwise.
Details
See
\Memcached::setMulti()
method public setOption (int $option, mixed $value) : bool

This method sets the vaue of a memcached option.

Parameters
Name Type Description
$option int

The option to set.

$value mixed

The value to set the option to.

Returns
Type Description
bool true if the call succeeds, false otherwise.
method public setOptions (mixed $options) : bool

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

Parameters
Name Type Description
$options mixed

An associated array of options.

Returns
Type Description
bool true if the call succeeds, false otherwise.
method public setSaslAuthData ( $username,  $password) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$username
$password
method public touch (string $key, int $expiration = 0) : bool

Sets a new expiration time on an item.

Parameters
Name Type Description
$key string

The key under which to append the value.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool true on success or false on failure.
method public touchByKey (string $server_key, string $key, int $expiration = 0) : bool

Functionally equivalent to Memcached::touch().

Parameters
Name Type Description
$server_key string

This parameter is ignored.

$key string

The key under which to append the value.

$expiration int

The expiration time, defaults to 0.

Returns
Type Description
bool true on success or false on failure.
Documentation was generated by phpDocumentor 2.0.0a12 .