Class MemcacheEngine
Memcache storage engine for cache. Memcache has some limitations in the amount of control you have over expire times far in the future. See MemcacheEngine::write() for more information.
- CacheEngine
- MemcacheEngine
Copyright: Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
License: License (http://www.opensource.org/licenses/mit-license.php)
Location: Cake/Cache/Engine/MemcacheEngine.php
Properties summary
-
$_Memcache
protectedMemcache
Memcache wrapper. -
$settings
publicarray
Settings
Method Summary
-
_parseServerString() protected
Parses the server address into the host/port. Handles both IPv6 and IPv4 addresses and Unix sockets
-
clear() public
Delete all keys from the cache -
connect() public
Connects to a server in connection pool -
decrement() public
Decrements the value of an integer cached key -
delete() public
Delete a key from the cache -
increment() public
Increments the value of an integer cached key -
init() public
Initialize the Cache Engine -
read() public
Read a key from the cache -
write() public
Write data for key into cache. When using memcache as your cache engine remember that the Memcache pecl extension does not support cache expiry times greater than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
Method Detail
_parseServerString() protected ¶
_parseServerString( string $server )
Parses the server address into the host/port. Handles both IPv6 and IPv4 addresses and Unix sockets
Parameters
- string $server
- The server address string.
Returns
Array containing host, port
clear() public ¶
clear( boolean $check )
Delete all keys from the cache
Parameters
- boolean $check
Returns
True if the cache was successfully cleared, false otherwise
connect() public ¶
connect( string $host , integer $port = 11211 )
Connects to a server in connection pool
Parameters
- string $host
- host ip address or name
- integer $port optional 11211
- Server port
Returns
True if memcache server was connected
decrement() public ¶
decrement( string $key , integer $offset = 1 )
Decrements the value of an integer cached key
Parameters
- string $key
- Identifier for the data
- integer $offset optional 1
- How much to subtract
Returns
decremented value, false otherwise
Throws
delete() public ¶
delete( string $key )
Delete a key from the cache
Parameters
- string $key
- Identifier for the data
Returns
True if the value was successfully deleted, false if it didn't exist or couldn't be removed
increment() public ¶
increment( string $key , integer $offset = 1 )
Increments the value of an integer cached key
Parameters
- string $key
- Identifier for the data
- integer $offset optional 1
- How much to increment
Returns
incremented value, false otherwise
Throws
init() public ¶
init( array $settings = array() )
Initialize the Cache Engine
Called automatically by the cache frontend To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
Parameters
- array $settings optional array()
- array of setting for the engine
Returns
True if the engine has been successfully initialized, false if not
Overrides
read() public ¶
read( string $key )
Read a key from the cache
Parameters
- string $key
- Identifier for the data
Returns
The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
write() public ¶
write( string $key , mixed $value , integer $duration )
Write data for key into cache. When using memcache as your cache engine remember that the Memcache pecl extension does not support cache expiry times greater than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
Parameters
- string $key
- Identifier for the data
- mixed $value
- Data to be cached
- integer $duration
- How long to cache the data, in seconds
Returns
True if the data was successfully cached, false on failure