You are here

class Cache in Render cache 7.2

Same name in this branch
  1. 7.2 src/Cache/Cache.php \Drupal\render_cache\Cache\Cache
  2. 7.2 lib/Drupal/Core/Cache/Cache.php \Drupal\Core\Cache\Cache

Helper methods for cache.

Hierarchy

  • class \Drupal\Core\Cache\Cache
    • class \Drupal\render_cache\Cache\Cache

Expanded class hierarchy of Cache

2 files declare their use of Cache
BaseController.php in src/RenderCache/Controller/BaseController.php
Contains \Drupal\render_cache\RenderCache\Controller\BaseController
CacheTest.php in tests/src/Cache/CacheTest.php
Contains \Drupal\render_cache\Tests\Cache\CacheTest

File

src/Cache/Cache.php, line 18
Contains \Drupal\render_cache\Cache\Cache.

Namespace

Drupal\render_cache\Cache
View source
class Cache extends D8Cache {

  /**
   * Generates a hash from a query object, to be used as part of the cache key.
   *
   * This smart caching strategy saves Drupal from querying and rendering to
   * HTML when the underlying query is unchanged.
   *
   * Expensive queries should use the query builder to create the query and then
   * call this function. Executing the query and formatting results should
   * happen in a #pre_render callback.
   *
   * Note: This function was overridden to provide the D7 version of
   *       SelectQueryInterface.
   *
   * @param \SelectQueryInterface
   *   A select query object.
   *
   * @return string
   *   A hash of the query arguments.
   */
  public static function keyFromQuery(SelectQueryInterface $query) {
    $query
      ->preExecute();
    $keys = array(
      (string) $query,
      $query
        ->getArguments(),
    );
    return hash('sha256', serialize($keys));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Cache::buildTags public static function Build an array of cache tags from a given prefix and an array of suffixes.
Cache::deleteTags public static function Deletes items from all bins with any of the specified tags.
Cache::getBins public static function Gets all cache bin services.
Cache::invalidateTags public static function Marks cache items from all bins with any of the specified tags as invalid.
Cache::keyFromQuery public static function Generates a hash from a query object, to be used as part of the cache key.
Cache::mergeTags public static function Merges arrays of cache tags and removes duplicates.
Cache::PERMANENT constant Indicates that the item should never be removed unless explicitly deleted.
Cache::validateTags public static function Validates an array of cache tags.