You are here

class ECKCache in Entity Construction Kit (ECK) 7.2

Same name and namespace in other branches
  1. 7.3 eck.classes.inc \ECKCache

A class that manages ECK caches.

Hierarchy

Expanded class hierarchy of ECKCache

File

./eck.classes.inc, line 819
Classes for all the different objects used in ECK.

View source
class ECKCache {
  private $id;
  private $data;

  /**
   * Inititate the ECK cache manager.
   *
   * @param string $id
   *   What are we caching or retriving? entity_type, bundle, etc.
   */
  public function __construct($id) {
    $this->id = $id;
  }

  /**
   * Set the cache.
   */
  public function set($data) {
    cache_set($this->id, $data, "cache_eck");
    $this->data = $data;
  }

  /**
   * Get something from the cache.
   */
  public function get() {
    if ($this->data) {
      return $this->data;
    }
    else {
      $cached_data = cache_get($this->id, "cache_eck");
      if ($cached_data) {
        $this->data = $cached_data->data;
        return $this->data;
      }
      else {
        return NULL;
      }
    }
  }

  /**
   * Reset the cache.
   */
  public function reset() {
    $this->data = NULL;
    cache_clear_all($this->id, 'cache_eck');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ECKCache::$data private property
ECKCache::$id private property
ECKCache::get public function Get something from the cache.
ECKCache::reset public function Reset the cache.
ECKCache::set public function Set the cache.
ECKCache::__construct public function Inititate the ECK cache manager.