class ShareaholicCache in Share Buttons, Related Posts, Content Analytics - Shareaholic 8
Same name and namespace in other branches
- 7.3 cache.php \ShareaholicCache
A simple wrapper around the Drupal caching library because it is incapable of respecting the expire time
@package shareaholic
Hierarchy
- class \ShareaholicCache
Expanded class hierarchy of ShareaholicCache
File
- ./
cache.php, line 14
View source
class ShareaholicCache {
/**
* Get the cached item based on the key
*
* @param string $key the key to get the cache value for
* @return mixed the data cached or false if not found
*/
public static function get($key) {
$cache = cache_get($key);
// check if the cache is stale
if (!$cache) {
return FALSE;
}
if (REQUEST_TIME > $cache->expire) {
return FALSE;
}
return $cache->data;
}
/**
* Updates the cache value given a key and expire time
*
* @param string $key the key for the cached data
* @param mixed $data the data to cache
* @param integer $expire the number of seconds to cache the data for
*/
public static function set($key, $data, $expire) {
$expire_time = REQUEST_TIME + $expire;
cache_set($key, $data, 'cache', $expire_time);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ShareaholicCache:: |
public static | function | Get the cached item based on the key | |
ShareaholicCache:: |
public static | function | Updates the cache value given a key and expire time |