Jump to main content Jump to doc navigation

xPDOCacheManager::set

Set a key-value pair in a cache provider.

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

  • format - If equals XPDO_CACHE_JSON, will set the string as the only data in file (rather than a return of the string. This is useful if you want more proper parsing of JSON data.

Syntax

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

boolean set (string $key, mixed &$var, [integer $lifetime = 0], [array $options = array()])

Example

Set a cache file to the string provided, to expire in 2 hours.

$str = 'This will be cached.';
$xpdo->cacheManager->set('mycachefile',$str,7200);

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