Jump to main content Jump to doc navigation

xPDOCacheManager::get

Get a value from a cache provider by key.

Also allows for an array of options to be passed. The current available values are:

  • format - If equals XPDO_CACHE_JSON, will simply get the contents of the array. This is useful if you set() the cache with XPDO_CACHE_JSON, to better handle JSON data.
  • removeIfEmpty - If set to true, will remove the cache file if it's empty. This is the default action.

Syntax

API Docs: http://api.modxcms.com/xpdo/cache/xPDOCacheManager.html#get

mixed get (string $key, [array $options = array()])

Example

Get the cache record 'test' into a string:

$test = $xpdo->cacheManager->get('test');

Get our JSON cache data called 'myjson':

$myJsonData = $xpdo->cacheManager->get('myjson',array('format' => xPDO::CACHE_JSON));

See Also

  1. xPDOCacheManager.copyFile
  2. xPDOCacheManager.copyTree
  3. xPDOCacheManager.delete
  4. xPDOCacheManager.deleteTree
  5. xPDOCacheManager.endsWith
  6. xPDOCacheManager.escapeSingleQuotes
  7. xPDOCacheManager.get
  8. xPDOCacheManager.getCachePath
  9. xPDOCacheManager.getCacheProvider
  10. xPDOCacheManager.matches
  11. xPDOCacheManager.replace
  12. xPDOCacheManager.writeFile
  13. xPDOCacheManager.set
  14. xPDOCacheManager.writeTree