Cache_ItemBase is an abstract class for implementing the key object that must be returned by implementors of the Cache_Engine interface. It provides methods for working with the value associated with its key.
It's worth mentioning the lock and unlock methods of this class. Both methods must be implemented, but they do not need to do anything if the associated engine does not support key-level locking. That is to say, derived classes do not need to override these methods if they do not implement locking. Similarly mtime() does not need to be overridden if it is not appropriate. See that method's documentation for more details.
Located in /cache/lib/Cache/ItemBase.php (line 20)
Class | Description |
---|---|
Cache_Engine_Apc_Item | The key object for the apc cache engine. |
Cache_Engine_File_Item | The key object for the file cache engine. |
Cache_Engine_Memcache_Item | The key object for the memcache cache engine. |
Cache_Engine_Memory_Item | The key object for the memory cache engine. |
Constructor
Test for the existence of the key in the cache. Return true if it exists, false otherwise.
Returns this item's key
Acquire a lock on the key. The method is expected to block until the lock is acquired.
As mentioned in the documentation for the class, this method does not need to acquire a lock if the engine does not support it. In that case it should simply return (this is the default implementation).
For engines that implement locking, the create flag may affect the behavior of this method. When the create flag is false, it indicates that the key will not be created if it does not already exist (as in the case of testing for the existence of a key). In this case, it is permissible to not actually lock the key if it does not exist (for example, if in order to lock the key it must first be created). If the create flag is true, engines supporting locking must lock the key and should create the key at this time if needed.
Given any value, returns a string representation of that value, serializing the value if necessary. This is convenient for preparing a value for storage for some engines.
Return the last modified time (as a Unix timestamp) of the value
associated with the key. This is used for testing TTL expiration when the underlying engine does not handle it automatically. If the underlying engine handles TTL itself, simply return false. The default implementation always returns false.
Return the value associated with the key from the cache
If the key does not have a value, this function must return null and it must not produce an exception.
Remove the key from the cache
Release any acquired lock for the key. As with lock(), this function should merely return (the default) if locking is not supported.
This is the inverse of marshall(). Given a string value returned by marshall, returns the original value.
Set the value associated with the key
Documentation generated on Wed, 25 Apr 2012 09:46:43 -0700 by phpDocumentor 1.4.3