Caching
Setup
To use xPDO's caching abilities, you'll first need to pass the XPDO_OPT_CACHE_PATH into the $options variable of the xPDO constructor. You can set it to the absolute path you would like xPDO to write your cache files to.
Caching Providers
xPDO supports extending the caching mechanism to different 'caching providers'. The default provider, xPDOFileCache, is file-based caching.
The base class, xPDOCache, can be extended to provide different caching solutions, and then one can pass in the cache file location into XPDO_OPT_CACHE_HANDLER to properly load the right extension.
The $xpdo->cacheManager object, built from the xPDOCacheManager class, is accessible after calling $xpdo->getCacheManager().
Manipulation of the Cache
A simple example script of setting data, then getting it, and deleting it, is as follows:
$str = 'My cached data.'; $xpdo->cacheManager->set('testdata',$str); echo $xpdo->cacheManager->get('testdata'); // outputs: My cached data. $xpdo->cacheManager->delete('testdata');
See Also
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).