An interface to the App Engine memory cache with an interface compatible with the "memcache" PHP extension (see http://php.net/manual/en/book.memcache.php)

All instances of this class use the same memory pool for their keys and values.

 Methods

Adds a new item to the cache.

add(string $key, mixed $value, int $flag, int $expire) : bool

Will fail if the key is already present in the cache.

Parameters

$key

string

The key associated with the value added to the cache.

$value

mixed

The value to add to the cache.

$flag

int

This parameter is present only for compatibility and is ignored.

$expire

int

The delay before the item is removed from the cache. If $expire <= 2592000 then it is interpreted as the number of seconds from the time of the call to wait before removing the item from the cache. If $expire > 2592000 then it is interpreted as the absolute Unix epoch time when the value will expire.

Returns

booltrue if the item was successfully added to the cache, false otherwise.

This function is present only for compatibility and does nothing.

addServer($host) 

Parameters

$host

This function is present only for compatibility and does nothing.

close() 

This function is present only for compatibility and does nothing.

connect($host, $port, $timeout) 

Parameters

$host

$port

$timeout

Decrements a cached item's value.

decrement(string $key, int $value) : mixed

The value must be a int, float or string representing an integer e.g. 5, 5.0 or "5" or the call with fail.

Parameters

$key

string

The key associated with the value to decrement.

$value

int

The amount to decrement the value.

Returns

mixedOn success, the new value of the item is returned. On failure, false is returned.

Deletes an item from the cache.

delete(string $key) : bool

Parameters

$key

string

The key associated with the item to delete.

Returns

booltrue if the item was successfully deleted from the cache, false otherwise. Note that this will return false if $key is not present in the cache.

Removes all items from cache.

flush() : bool

Returns

booltrue if all items were removed, false otherwise.

Fetches previously stored data from the cache.

get(string | string[] $keys, int $flags) : mixed

Parameters

$keys

stringstring[]

The key associated with the value to fetch, or an array of keys if fetching multiple values.

$flags

int

This parameter is present only for compatibility and is ignored. It should return the stored flag value.

Returns

mixedOn success, the string associated with the key, or an array of key-value pairs when $keys is an array. On failure, false is returned.

Increments a cached item's value.

increment(string $key, int $value) : mixed

The value must be a int, float or string representing an integer e.g. 5, 5.0 or "5" or the call with fail.

Parameters

$key

string

The key associated with the value to increment.

$value

int

The amount to increment the value.

Returns

mixedOn success, the new value of the item is returned. On failure, false is returned.

This function is present only for compatibility and does nothing.

pconnect($host, $port, $timeout) 

Parameters

$host

$port

$timeout

Replaces an existing item in the cache.

replace(string $key, mixed $value, int $flag, int $expire) : bool

Will fail if the key is not already present in the cache.

Parameters

$key

string

The key associated with the value that will be replaced in the cache.

$value

mixed

The new cache value.

$flag

int

This parameter is present only for compatibility and is ignored.

$expire

int

The delay before the item is removed from the cache. If $expire <= 2592000 then it is interpreted as the number of seconds from the time of the call to wait before removing the item from the cache. If $expire > 2592000 then it is interpreted as the absolute Unix epoch time when the value will expire.

Returns

booltrue if the item was successfully replaced in the cache, false otherwise.

Sets the value of a key in the cache regardless of whether it is currently present or not.

set(string $key, mixed $value, int $flag, int $expire) : bool

Parameters

$key

string

The key associated with the value that will be replaced in the cache.

$value

mixed

The new cache value.

$flag

int

This parameter is present only for compatibility and is ignored.

$expire

int

The delay before the item is removed from the cache. If $expire <= 2592000 then it is interpreted as the number of seconds from the time of the call to wait before removing the item from the cache. If $expire > 2592000 then it is interpreted as the absolute Unix epoch time when the value will expire.

Returns

booltrue if the item was successfully replaced the cache, false otherwise.

This function is present only for compatibility and does nothing.

setCompressThreshold($threshold, $min_savings) 

Parameters

$threshold

$min_savings