You are here

function _authcache_key in Authenticated User Page Caching (Authcache) 7

Same name and namespace in other branches
  1. 6 authcache.helpers.inc \_authcache_key()

Returns caching key based on user's role.

This is prefixed to the URL in the cache_page bin.

2 calls to _authcache_key()
authcache_user_login in ./authcache.module
Implements hook_user().
_authcache_shutdown_save_page in ./authcache.helpers.inc
Save page to cache

File

./authcache.helpers.inc, line 421
Helper functions for the Authcache module (no Drupal hooks here).

Code

function _authcache_key($account) {
  if ($authcache_keygen = variable_get('authcache_key_generator', FALSE)) {

    // Call the user specified key generator
    return $authcache_keygen($account);
  }
  else {

    // No custom key generator defined so use the default=
    if (!$account->uid) {
      return '';
    }
    $keys = implode('.', array_keys($account->roles));
    $key = md5($keys . drupal_get_private_key());

    // Make sure superuser has its own key not shared with anyone else (though
    // it would be better if superuser would'nt be allowed to use the cache in
    // the first place).
    if ($account->uid == 1) {
      $key = md5($key . $keys . drupal_get_private_key());
    }
    return substr($key, 0, 6);
  }
}