runtime/Memcache.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.

Functions

functionmemcache_add(\Memcache $memcache_obj, string $key, mixed $value, int $flag = null, int $expire = 0) : bool

Adds a new item to the cache.

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

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to add item to.

$keystring

The key associated with the value added to the cache.

$valuemixed

The value to add to the cache.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully added to the cache, false otherwise.
functionmemcache_add_server( $memcache_obj,  $host) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$memcache_obj
$host
functionmemcache_close( $memcache_obj) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$memcache_obj
functionmemcache_connect( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$host
$port
$timeout
functionmemcache_decrement(\Memcache $memcache_obj, string $key, int $value = 1) : mixed

Decrements a cached item's value.

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
NameTypeDescription
$memcache_obj\Memcache

The cache instance to decrement the value in.

$keystring

The key associated with the value to decrement.

$valueint

The amount to decrement the value.

Returns
TypeDescription
mixedOn success, the new value of the item is returned. On failure, false is returned.
functionmemcache_delete(\Memcache $memcache_obj, string $key) : bool

Deletes an item from the cache.

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to delete the item from.

$keystring

The key associated with the item to delete.

Returns
TypeDescription
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.
functionmemcache_flush(\Memcache $memcache_obj) : bool

Removes all items from cache.

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to flush.

Returns
TypeDescription
booltrue if all items were removed, false otherwise.
functionmemcache_get(\Memcache $memcache_obj, string | string[] $keys, int $flags = null) : mixed

Fetches previously stored data from the cache.

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to get the item from.

$keysstring | string[]

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

$flagsint

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

Returns
TypeDescription
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.
functionmemcache_increment(\Memcache $memcache_obj, string $key, int $value = 1) : mixed

Increments a cached item's value.

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
NameTypeDescription
$memcache_obj\Memcache

The cache instance to increment the value in.

$keystring

The key associated with the value to decrement.

$valueint

The amount to increment the value.

Returns
TypeDescription
mixedOn success, the new value of the item is returned. On failure, false is returned.
functionmemcache_pconnect( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$host
$port
$timeout
functionmemcache_replace(\Memcache $memcache_obj, string $key, mixed $value, int $flag = null, int $expire = 0) : bool

Replaces an existing item in the cache.

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

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to store the item in.

$keystring

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

$valuemixed

The new cache value.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully replaced in the cache, false otherwise.
functionmemcache_set(\Memcache $memcache_obj, string $key, mixed $value, int $flag = null, int $expire = 0) : bool

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

Parameters
NameTypeDescription
$memcache_obj\Memcache

The cache instance to store the item in.

$keystring

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

$valuemixed

The new cache value.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully replaced the cache, false otherwise.
functionmemcache_set_compress_threshold( $memcache_obj,  $threshold,  $min_savings = 0.2) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$memcache_obj
$threshold
$min_savings

\Memcache

Package: Default
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

methodpublicadd(string $key, mixed $value, int $flag = null, int $expire = 0) : bool

Adds a new item to the cache.

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

Parameters
NameTypeDescription
$keystring

The key associated with the value added to the cache.

$valuemixed

The value to add to the cache.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully added to the cache, false otherwise.
methodpublicaddServer( $host) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$host
methodpublicclose() : void

This function is present only for compatibility and does nothing.

methodpublicconnect( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$host
$port
$timeout
methodpublicdecrement(string $key, int $value = 1) : mixed

Decrements a cached item's value.

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
NameTypeDescription
$keystring

The key associated with the value to decrement.

$valueint

The amount to decrement the value.

Returns
TypeDescription
mixedOn success, the new value of the item is returned. On failure, false is returned.
methodpublicdelete(string $key) : bool

Deletes an item from the cache.

Parameters
NameTypeDescription
$keystring

The key associated with the item to delete.

Returns
TypeDescription
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.
methodpublicflush() : bool

Removes all items from cache.

Returns
TypeDescription
booltrue if all items were removed, false otherwise.
methodpublicget(string | string[] $keys, int $flags = null) : mixed

Fetches previously stored data from the cache.

Parameters
NameTypeDescription
$keysstring | string[]

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

$flagsint

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

Returns
TypeDescription
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.
methodpublicincrement(string $key, int $value = 1) : mixed

Increments a cached item's value.

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
NameTypeDescription
$keystring

The key associated with the value to decrement.

$valueint

The amount to increment the value.

Returns
TypeDescription
mixedOn success, the new value of the item is returned. On failure, false is returned.
methodpublicpconnect( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$host
$port
$timeout
methodpublicreplace(string $key, mixed $value, int $flag = null, int $expire = 0) : bool

Replaces an existing item in the cache.

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

Parameters
NameTypeDescription
$keystring

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

$valuemixed

The new cache value.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully replaced in the cache, false otherwise.
methodpublicset(string $key, mixed $value, int $flag = null, int $expire = 0) : bool

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

Parameters
NameTypeDescription
$keystring

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

$valuemixed

The new cache value.

$flagint

This parameter is present only for compatibility and is ignored.

$expireint

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
TypeDescription
booltrue if the item was successfully replaced the cache, false otherwise.
methodpublicsetCompressThreshold( $threshold,  $min_savings = 0.2) : void

This function is present only for compatibility and does nothing.

Parameters
NameTypeDescription
$threshold
$min_savings
Documentation was generated by phpDocumentor 2.0.0a12.