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

Constants

> V Constant MEMCACHE_COMPRESSED = 2
> V Constant MEMCACHE_HAVE_SESSION = 1

Functions

function memcache_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
Name Type Description
$memcache_obj \Memcache

The cache instance to add item to.

$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
Type Description
bool true if the item was successfully added to the cache, false otherwise.
function memcache_add_server ( $memcache_obj,  $host) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$memcache_obj
$host
function memcache_close ( $memcache_obj) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$memcache_obj
function memcache_connect ( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
$port
$timeout
function memcache_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
Name Type Description
$memcache_obj \Memcache

The cache instance to decrement the value in.

$key string

The key associated with the value to decrement.

$value int

The amount to decrement the value.

Returns
Type Description
mixed On success, the new value of the item is returned. On failure, false is returned.
function memcache_delete ( \Memcache $memcache_obj, string $key) : bool

Deletes an item from the cache.

Parameters
Name Type Description
$memcache_obj \Memcache

The cache instance to delete the item from.

$key string

The key associated with the item to delete.

Returns
Type Description
bool true 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.
function memcache_flush ( \Memcache $memcache_obj) : bool

Removes all items from cache.

Parameters
Name Type Description
$memcache_obj \Memcache

The cache instance to flush.

Returns
Type Description
bool true if all items were removed, false otherwise.
function memcache_get ( \Memcache $memcache_obj, string | string[] $keys, int $flags = null) : mixed

Fetches previously stored data from the cache.

Parameters
Name Type Description
$memcache_obj \Memcache

The cache instance to get the item from.

$keys string | string[]

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
Type Description
mixed On success, the string associated with the key, or an array of key-value pairs when $keys is an array. On failure, false is returned.
function memcache_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
Name Type Description
$memcache_obj \Memcache

The cache instance to increment the value in.

$key string

The key associated with the value to increment.

$value int

The amount to increment the value.

Returns
Type Description
mixed On success, the new value of the item is returned. On failure, false is returned.
function memcache_pconnect ( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
$port
$timeout
function memcache_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
Name Type Description
$memcache_obj \Memcache

The cache instance to store the item in.

$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
Type Description
bool true if the item was successfully replaced in the cache, false otherwise.
function memcache_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
Name Type Description
$memcache_obj \Memcache

The cache instance to store the item in.

$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
Type Description
bool true if the item was successfully replaced the cache, false otherwise.
function memcache_set_compress_threshold ( $memcache_obj,  $threshold,  $min_savings = 0.2) : void

This function is present only for compatibility and does nothing.

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

method public add (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
Name Type Description
$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
Type Description
bool true if the item was successfully added to the cache, false otherwise.
method public addServer ( $host) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
method public close () : void

This function is present only for compatibility and does nothing.

method public connect ( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
$port
$timeout
method public decrement (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
Name Type Description
$key string

The key associated with the value to decrement.

$value int

The amount to decrement the value.

Returns
Type Description
mixed On success, the new value of the item is returned. On failure, false is returned.
method public delete (string $key) : bool

Deletes an item from the cache.

Parameters
Name Type Description
$key string

The key associated with the item to delete.

Returns
Type Description
bool true 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.
method public flush () : bool

Removes all items from cache.

Returns
Type Description
bool true if all items were removed, false otherwise.
method public get (string | string[] $keys, int $flags = null) : mixed

Fetches previously stored data from the cache.

Parameters
Name Type Description
$keys string | string[]

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
Type Description
mixed On success, the string associated with the key, or an array of key-value pairs when $keys is an array. On failure, false is returned.
method public increment (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
Name Type Description
$key string

The key associated with the value to increment.

$value int

The amount to increment the value.

Returns
Type Description
mixed On success, the new value of the item is returned. On failure, false is returned.
method public pconnect ( $host,  $port = null,  $timeout = 1) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$host
$port
$timeout
method public replace (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
Name Type Description
$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
Type Description
bool true if the item was successfully replaced in the cache, false otherwise.
method public set (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
Name Type Description
$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
Type Description
bool true if the item was successfully replaced the cache, false otherwise.
method public setCompressThreshold ( $threshold,  $min_savings = 0.2) : void

This function is present only for compatibility and does nothing.

Parameters
Name Type Description
$threshold
$min_savings
Documentation was generated by phpDocumentor 2.0.0a12 .