LiveWhale CMS

Welcome, Guest Login

Support Center

Our documentation is moving: docs.livewhale.com

Please check docs.livewhale.com for the most up-to-date LiveWhale CMS and LiveWhale Calendar documentation. The below legacy documentation will remain available as a reference until the documentation migration is complete.

Using LiveWhale Persistent Cache

Last Updated: Nov 26, 2014 02:53PM PST

In some instances, you may want to cache values frequently retrieved by your custom modules, especially if they require intense calculations to produce.

LiveWhale offers access to its own persistent cache with four built-in framework functions:

// Returns a previously set value for the varname key, or FALSE if not set.
$_LW->getVariable('varname');
// Sets the varname key to $value, overwriting any previous value.
// This method returns TRUE on success or FALSE on failure. 
//$ttl is optional and disabled if not set. This can be used to cache for a specified time (ex., $ttl=3600 //1 hour)
$_LW->setVariable('varname', $value, $ttl=0);

//Returns the mtime of the current variable if it exists (i.e., the last time modified)
$_LW->getVariableMTime('varname');
// Removes the value set for the 'varname' key.
// This method returns TRUE on success or FALSE on failure.
$_LW->removeVariable('varname');
// Returns TRUE/FALSE if the 'varname' key has been set; useful when the saved value is boolean.
$_LW->hasVariable('varname');

 

LiveWhale uses APC methods when APC has been installed, or writes the values to disk should it not.

eb8f96c071020d8b0923da726d6cab65@livewhale.desk-mail.com
https://cdn.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete?b_id=4256