You are here

class ECKCache in Entity Construction Kit (ECK) 7.3

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

Hierarchy

Expanded class hierarchy of ECKCache

File

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

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

  /**
   * Constructor.
   */
  public function __construct($id) {
    $this->id = $id;
    $this->noCache = FALSE;
    if (!db_table_exists('cache_eck')) {
      $this->noCache = TRUE;
    }
  }

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

  /**
   * Get.
   */
  public function get() {
    if ($this->noCache) {
      return NULL;
    }
    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.
   */
  public function reset() {
    if ($this->noCache) {
      return;
    }
    $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::$noCache private property
ECKCache::get public function Get.
ECKCache::reset public function Reset.
ECKCache::set public function Set.
ECKCache::__construct public function Constructor.