This is an implementation of the Cache interface using APC. It is a very straightforward mapping of the interface methods to the APC functions. An notable difference is that cache slams are not allowed, so store will fail to store where apc_store would succeed.
Implements
Defined in:
Cache/ApcCache.php.
Attr. | Name / Description |
---|---|
public |
ApcCache() Create an APC cache wrapper. |
Name | Description |
---|---|
CACHE_SLAM | Constant to indicate that a value was not stored in the cache because the entry was already taken. |
DATA_STORED | Constant to indicate that a value was succesfully stored in the cache. |
NO_SPACE | Constant to indicate that a value was not stored in the cache because there was not enough storage available. |
Attr. | Type | Name / Description |
---|---|---|
public |
delete($key) Delete/remove a cache entry. |
|
public | object[] |
List all entries in the cache. |
public | mixed |
fetch($key) Retrieve a value from the cache. |
public | int |
overwrite($key, $val, $ttl) Store a variable in the cache, overwrite it if it already exists. |
public | int |
store($key, $val, $ttl) Store a variable in the cache. |
Constructor
- public ApcCache()
-
Create an APC cache wrapper.
View source: Cache/ApcCache.php line 51.
Constants
- CACHE_SLAM
-
Constant to indicate that a value was not stored in the cache because the entry was already taken.
Inherited from \Scrivo\Cache
Value: 2
View source: Cache.php line 54.
- DATA_STORED
-
Constant to indicate that a value was succesfully stored in the cache.
Inherited from \Scrivo\Cache
Value: 1
View source: Cache.php line 48.
- NO_SPACE
-
Constant to indicate that a value was not stored in the cache because there was not enough storage available.
Inherited from \Scrivo\Cache
Value: 3
View source: Cache.php line 60.
Methods
- public delete(\Scrivo\String $key)
-
Delete/remove a cache entry.
Parameters:
Type Name Def. Description \Scrivo\String $key A cache unique name for the key.
View source: Cache/ApcCache.php line 112.
- public object[] entryList()
-
List all entries in the cache.
This method returns an array in which the cache keys are the keys of the array entries and the data of each entry is an object of type stdClass that contains at least the following properties:
- accessed: the access time
- expires: the expiration time
- created: the creation time
- size: the size of the entry
Returns:
object[] List all entries in the cache.
View source: Cache/ApcCache.php line 144.
- public mixed fetch(\Scrivo\String $key)
-
Retrieve a value from the cache.
Parameters:
Type Name Def. Description \Scrivo\String $key The key for which to retrieve the value.
Returns:
mixed Retrieve a value from the cache.
View source: Cache/ApcCache.php line 124.
- public int overwrite(\Scrivo\String $key, mixed $val, int $ttl=3600)
-
Store a variable in the cache, overwrite it if it already exists.
Store any serializable variable in the cache. It is guaranteed that the data will be written. But note that it is not guaranteed that the next fetch will retrieve this value.
Parameters:
Type Name Def. Description \Scrivo\String $key A cache unique name for the key.
mixed $val The (serializable) variabele to strore.
int $ttl 3600 Time to live in seconds.
Returns:
int Store a variable in the cache, overwrite it if it already exists.
Throws:
Exception Type Description \Scrivo\SystemException When trying to store a NULL value or when a file operation fails. View source: Cache/ApcCache.php line 98.
- public int store(\Scrivo\String $key, mixed $val, int $ttl=3600)
-
Store a variable in the cache.
Store any serializable variable in the cache. Note that it is not possible to overwrite an existing entry (cache slam). Such an event will not raise an error but the function will report it.
Parameters:
Type Name Def. Description \Scrivo\String $key A cache unique name for the key.
mixed $val The (serializable) variabele to strore.
int $ttl 3600 Time to live in seconds.
Returns:
int Store a variable in the cache.
Throws:
Exception Type Description \Scrivo\SystemException When trying to store a NULL value. View source: Cache/ApcCache.php line 70.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013