You are here

function api_tokens_cache_id in API Tokens 7

Generates token cache id in accordance with caching types.

1 call to api_tokens_cache_id()
api_tokens_render in ./api_tokens.module
Processes API tokens.

File

./api_tokens.module, line 214
The API Tokens module

Code

function api_tokens_cache_id($token, $params) {
  global $user;

  // Building token cache ID.
  $hash = array(
    $params,
  );
  DRUPAL_CACHE_PER_ROLE & $token['cache'] && ($hash[1] = implode(',', $user->roles));
  DRUPAL_CACHE_PER_USER & $token['cache'] && ($hash[2] = $user->uid);
  DRUPAL_CACHE_PER_PAGE & $token['cache'] && ($hash[3] = $_GET['q']);
  $cid = 'apitoken:' . $token['key'] . ':' . md5(serialize($hash));
  return $cid;
}