google/appengine/runtime/Memcached.php
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
Constants
Methods
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.
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. |
Type | Description |
---|---|
bool | true on success, false on failure. |
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.
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. |
Type | Description |
---|---|
bool | true on success, false on failure. |
addServer
( $host, $port, $weight = 0)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host | ||
$port | ||
$weight |
addServers
( $servers)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$servers |
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.
Name | Type | Description |
---|---|---|
$key | string |
The key under which to append the value. |
$value | string |
The value to append |
- Result
- bool Returns true on success or false on failure.
appendByKey
(string $server_key, string $key, string $value)
: void
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 |
- Result
- bool Returns true on success or false on failure.
- See
- \Memcached::append().
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.
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. |
Type | Description |
---|---|
bool | True on success, or false on failure. |
casByKey
(mixed $cas_token, string $server_key, string $key, mixed $value, int $expiration = 0)
: bool
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. |
Type | Description |
---|---|
bool | True on success, or false on failure. |
decrement
(string $key, int $offset = 1, int $initial_value = 0, int $expiration = 0)
: bool
Decrements a numeric item's value by $offset.
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. |
Type | Description |
---|---|
bool | True on success, or false on failure. |
decrementByKey
(string $server_key, string $key, int $offset = 1, int $initial_value = 0, int $expiration = 0)
: bool
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. |
Type | Description |
---|---|
bool | True on success, or false on failure. |
delete
(string $key, int $time = 0)
: bool
deletes the $key from the server.
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. |
Type | Description |
---|---|
bool | true on success or false on failure. |
deleteByKey
(string $server_key, string $key, int $time = 0)
: bool
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. |
Type | Description |
---|---|
bool | true on success or false on failure. |
deleteMulti
(array $keys, int $time = 0)
: bool
deletes an array of $keys from the server.
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. |
Type | Description |
---|---|
bool | true on success or false on failure. |
deleteMultiByKey
(string $server_key, array $keys, int $time = 0)
: bool
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. |
Type | Description |
---|---|
bool | true on success or false on failure. |
fetch
()
: \The
fetch retrieves the next result from the last getDelayed() request.
Note that currently getDelayed is a synchronous call.
Type | Description |
---|---|
\The | next result, or false if there are no more results. |
fetchAll
()
: array
Fetch all of the remaining results from the last getDelayed() request.
Note that currently getDelayed is a synchronous call.
Type | Description |
---|---|
array | The remaining results, or false if there are no results. |
flush
(int $delay = 0)
: bool
Invalidates all existing cache items immediately.
Name | Type | Description |
---|---|---|
$delay | int |
This parameter is ignored. |
Type | Description |
---|---|
bool | true on success, or false on failure. |
get
(string $key, callable $cache_cb = null, mixed $cas_token = null)
: \the
Returns the item that was previously stored under the $key.
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. |
Type | Description |
---|---|
\the | value stored in the cache of false if there was a failure. |
getByKey
(string $server_key, string $key, callable $cache_cb, mixed $cas_token)
: \the
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. |
Type | Description |
---|---|
\the | value stored in the cache of false if there was a failure. |
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.
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. |
Type | Description |
---|---|
bool | true on success, or false on failure. |
getDelayedByKey
(string $server_key, array $keys, bool $with_cas = false, callable $value_cb = null)
: bool
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. |
Type | Description |
---|---|
bool | true on success, or false on failure. |
- See
- \getDelayedByKey.
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.
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. |
Type | Description |
---|---|
array | The array of found items for false on failure. |
getMultiByKey
(string $server_key, array $keys, $with_cas = false, $value_cb = null)
: array
Name | Type | Description |
---|---|---|
$server_key | string |
This parameter is ignored. |
$keys | array |
Array of keys to retrieve. |
$with_cas | ||
$value_cb |
Type | Description |
---|---|
array | The array of found items for false on failure. |
getOption
( $option)
: mixed
Retrieve a Memcached option value.
Name | Type | Description |
---|---|---|
$option |
Type | Description |
---|---|
mixed | the value of the requested option, of false on error. |
- Params
- int $option One of the Memcached::OPT_* constants.
getResultCode
()
: int
Returns one of the Memcached::RES_* constants that is the result of the last executed Memcached method.
Type | Description |
---|---|
int | The result code of the last memcached operation. |
getResultMessage
()
: string
Return the message describing the result of the last operation.
Type | Description |
---|---|
string | Message describing the result of the last operation. |
getServerByKey
( $server_key)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$server_key |
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.
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. |
Type | Description |
---|---|
\The | new item's value on success or false on failure. |
incrementByKey
(string $server_key, string $key, int $offset = 1, int $initial_value = 0, int $expiry = 0)
: \The
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. |
Type | Description |
---|---|
\The | new item's value on success or false on failure. |
prepend
(string $key, string $value)
: true
Prepends the given value string to an existing item.
Name | Type | Description |
---|---|---|
$key | string |
The key under which to store the value. |
$value | string |
The string to prepend. |
Type | Description |
---|---|
true | on success or false on failure. |
prependByKey
(string $server_key, string $key, string $value)
: true
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. |
Type | Description |
---|---|
true | on success or false on failure. |
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.
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. |
Type | Description |
---|---|
true | if the method succeeds, false on failure. |
replaceByKey
(string $server_key, string $key, mixed $value, int $expiration = 0)
: true
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. |
Type | Description |
---|---|
true | if the method succeeds, false on failure. |
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.
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. |
Type | Description |
---|---|
true | if the method succeeds, false on failure. |
setByKey
(string $server_key, string $key, mixed $value, int $expiration = 0)
: true
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. |
Type | Description |
---|---|
true | if the method succeeds, false on failure. |
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.
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. |
setMultiByKey
(string $server_key, array $items, int $expiration = 0)
: bool
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. |
Type | Description |
---|---|
bool | true if the call succeeds, false otherwise. |
setOption
(int $option, mixed $value)
: bool
This method sets the vaue of a memcached option.
Name | Type | Description |
---|---|---|
$option | int |
The option to set. |
$value | mixed |
The value to set the option to. |
Type | Description |
---|---|
bool | true if the call succeeds, false otherwise. |
setOptions
(mixed $options)
: bool
This is a varion of Memcached::setOption() that takes an array of options to be set.
Name | Type | Description |
---|---|---|
$options | mixed |
An associated array of options. |
Type | Description |
---|---|
bool | true if the call succeeds, false otherwise. |
setSaslAuthData
( $username, $password)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$username | ||
$password |
touch
(string $key, int $expiration = 0)
: bool
Sets a new expiration time on an item.
Name | Type | Description |
---|---|---|
$key | string |
The key under which to append the value. |
$expiration | int |
The expiration time, defaults to 0. |
Type | Description |
---|---|
bool | true on success or false on failure. |
touchByKey
(string $server_key, string $key, int $expiration = 0)
: bool
Functionally equivalent to Memcached::touch().
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. |
Type | Description |
---|---|
bool | true on success or false on failure. |