function api_tokens_cache_get in API Tokens 7
API Tokens cache_get wrapper connected to static storage.
1 call to api_tokens_cache_get()
- api_tokens_render in ./
api_tokens.module - Processes API tokens.
1 string reference to 'api_tokens_cache_get'
- api_tokens_cache_set in ./
api_tokens.module - API Tokens cache_set wrapper connected to static storage.
File
- ./
api_tokens.module, line 176 - The API Tokens module
Code
function api_tokens_cache_get($cids) {
$cache =& drupal_static(__FUNCTION__, FALSE);
$data = array();
// Checking in static storage.
foreach ($cids as $i => $cid) {
if (isset($cache[$cid])) {
$data[$i] = $cache[$cid];
unset($cids[$i]);
}
}
// If not all cids are found in static storage, cheching DB cache.
if (count($cids)) {
// Creating a reference to $cids and passing it to cache_get
// as $cids will be overriden after the call.
$cids_ref = $cids;
$cache_ext = cache_get_multiple($cids_ref);
foreach ($cids as $i => $cid) {
// Checking if DB cache exists and its expiration date.
if (isset($cache_ext[$cid]) && (0 >= $cache_ext[$cid]->expire || 0 < $cache_ext[$cid]->expire && REQUEST_TIME <= $cache_ext[$cid]->expire)) {
// Storing to static.
$cache[$cid] = $cache_ext[$cid]->data;
$data[$i] = $cache[$cid];
}
else {
$data[$i] = FALSE;
}
}
}
return $data;
}