google/appengine/runtime/Memcache.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.
Constants
Functions
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully added to the cache, false otherwise. |
memcache_add_server
( $memcache_obj, $host)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$memcache_obj | ||
$host |
memcache_close
( $memcache_obj)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$memcache_obj |
memcache_connect
( $host, $port = null, $timeout = 1)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host | ||
$port | ||
$timeout |
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.
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. |
Type | Description |
---|---|
mixed | On success, the new value of the item is returned. On failure, false is returned. |
memcache_delete
(
\Memcache
$memcache_obj, string $key)
: bool
Deletes an item from the cache.
Name | Type | Description |
---|---|---|
$memcache_obj | \Memcache |
The cache instance to delete the item from. |
$key | string |
The key associated with the item to delete. |
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. |
memcache_flush
(
\Memcache
$memcache_obj)
: bool
Removes all items from cache.
Name | Type | Description |
---|---|---|
$memcache_obj | \Memcache |
The cache instance to flush. |
Type | Description |
---|---|
bool | true if all items were removed, false otherwise. |
memcache_get
(
\Memcache
$memcache_obj, string | string[] $keys, int $flags = null)
: mixed
Fetches previously stored data from the cache.
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. |
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. |
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.
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. |
Type | Description |
---|---|
mixed | On success, the new value of the item is returned. On failure, false is returned. |
memcache_pconnect
( $host, $port = null, $timeout = 1)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host | ||
$port | ||
$timeout |
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully replaced in the cache, false otherwise. |
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully replaced the cache, false otherwise. |
\Memcache
All instances of this class use the same memory pool for their keys and values.
Methods
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully added to the cache, false otherwise. |
addServer
( $host)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host |
connect
( $host, $port = null, $timeout = 1)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host | ||
$port | ||
$timeout |
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.
Name | Type | Description |
---|---|---|
$key | string |
The key associated with the value to decrement. |
$value | int |
The amount to decrement the value. |
Type | Description |
---|---|
mixed | On success, the new value of the item is returned. On failure, false is returned. |
delete
(string $key)
: bool
Deletes an item from the cache.
Name | Type | Description |
---|---|---|
$key | string |
The key associated with the item to delete. |
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. |
flush
()
: bool
Removes all items from cache.
Type | Description |
---|---|
bool | true if all items were removed, false otherwise. |
get
(string | string[] $keys, int $flags = null)
: mixed
Fetches previously stored data from the cache.
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. |
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. |
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.
Name | Type | Description |
---|---|---|
$key | string |
The key associated with the value to increment. |
$value | int |
The amount to increment the value. |
Type | Description |
---|---|
mixed | On success, the new value of the item is returned. On failure, false is returned. |
pconnect
( $host, $port = null, $timeout = 1)
: void
This function is present only for compatibility and does nothing.
Name | Type | Description |
---|---|---|
$host | ||
$port | ||
$timeout |
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully replaced in the cache, false otherwise. |
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.
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. |
Type | Description |
---|---|
bool | true if the item was successfully replaced the cache, false otherwise. |