kijin / ooapc
An object-oriented interface to APC, drop-in replacement for Memcache class
dev-master
2013-05-28 16:05 UTC
Requires
- php: >=5.0.0
- ext-apc: >=3.1.1
This package is not auto-updated.
Last update: 2024-11-19 07:21:38 UTC
README
OOAPC: An object-oriented interface to APC ========================================== This class exposes an object-oriented interface to APC functions. The interface can also serve as a drop-in replacement for the Memcache class, except connection-related methods which are unnecessary in the case of APC. Code Example: $apc = new OOAPC; $apc->set($key, $value, $ttl); // $value will be automatically serialized. echo $apc->get($key); Methods Reference: is_enabled() Returns true if APC is enabled, and false otherwise. get($key) Returns the cached value, or false if the key is not found. set($key, $value, [$ttl = 0], [$ttl = 0]) Stores the value under the key, whether or not the key exists. Returns true on success and false on failure. add($key, $value, [$ttl = 0], [$ttl = 0]) Stores the value under the key, only if the key does not already exist. Returns true on success and false on failure. replace($key, $value, [$ttl = 0], [$ttl = 0]) Stores the value under the key, only if the key already exists. Returns true on success and false on failure. delete($key) Deletes the key. Returns true on success and false on failure. increment($key, [$diff = 1]) Increments an integer stored under the key. If the key is not found or the value is not an integer, this will fail. Returns the new value, or false on failure. decrement($key, [$diff = 1]) Decrements an integer stored under the key. If the key is not found or the value is not an integer, this will fail. Returns the new value, or false on failure. flush() Deletes all keys from the APC user cache. For compatibility with Memcache, the TTL can be specified using either the third or the fourth argument of set(), add(), and replace() methods. If the fourth argument is set, it will override the third argument. Known Issues: replace() is not an atomic operation, because APC does not provide the equivalent of Memcache's replace() method. It is therefore possible for a key to be deleted after it is checked for existence but before the new value is stored. In APC versions 3.1.8 and below, set() and replace() may occasionally fail, especially when they are called repeatedly on the same key. For more information, please see http://pecl.php.net/bugs/bug.php?id=16814 License: OOAPC is free software, released under the MIT License.