You are here

public static function fastcache::Enabled in Drupal driver for SQL Server and SQL Azure 7.3

Same name and namespace in other branches
  1. 7.2 sqlsrv/fastcache.inc \fastcache::Enabled()

Tell if cache persistence is enabled. If not, this cache will behave as DRUPAL_STATIC until the end of request.

Only enable this cache if the backend is DrupalWinCache and the lock implementation is DrupalWinCache

2 calls to fastcache::Enabled()
fastcache::cache_load_ensure in sqlsrv/fastcache.inc
Ensure cache binary is statically loaded.
fastcache::cache_set in sqlsrv/fastcache.inc
cache_set wrapper.

File

sqlsrv/fastcache.inc, line 84

Class

fastcache
Static caching layer.

Code

public static function Enabled($refresh = FALSE) {
  if (static::$enabled === NULL || $refresh) {

    // Make sure _cache_get_object exists, if fastache
    // used out of database driver there is a chance that
    // cache storage might not yet be initialized.
    if (function_exists('_cache_get_object')) {

      // Only enabled storage if Cache Backend is DrupalWinCache or ChainedFastBackend.
      $object = _cache_get_object('fastcache');
      static::$enabled = is_a($object, \DrupalWinCache::class) || is_a($object, \ChainedFastBackend::class);
    }
    else {
      static::$enabled = FALSE;
    }
  }
  return static::$enabled;
}