You are here

abstract class Messaging_Cached_Object in Messaging 6.4

Class with static caching

Hierarchy

Expanded class hierarchy of Messaging_Cached_Object

File

includes/messaging_object.class.inc, line 277
Drupal Messaging Framework - Base classes

View source
abstract class Messaging_Cached_Object extends Messaging_Object {

  /**
   * Load object by unique key, may have static caching
   */
  public static function object_load($table, $key, $value, $class) {
    $cached = self::object_cache_get($class, $value);
    if (isset($cached)) {
      return $cached;
    }
    elseif ($object = parent::object_load($table, $key, $value, $class)) {
      $object
        ->cache_save();
      return $object;
    }
    else {
      self::object_cache_set($class, $value, FALSE);
    }
  }

  /**
   *   /**
   * Create object in database
   */
  public function insert() {
    $result = parent::insert();
    $this
      ->cache_save();
    return $result;
  }

  /**
   * Delete from system and from static cache
   */
  function delete() {
    if ($this
      ->key()) {
      $this
        ->cache_delete();
      return parent::delete();
    }
  }

  /**
   * Save object to cache
   */
  public function cache_save() {
    $this
      ->cache_set($this
      ->key(), $this);
  }

  /**
   * Delete object from cache
   */
  public function cache_delete() {
    $this
      ->cache_set($this
      ->key(), FALSE);
  }

  /**
   * Set value into static cache
   */
  protected static function object_cache_set($class_name, $key, $value) {
    return messaging_static_cache_set($class_name, $key, $value);
  }

  /**
   * Get value from static cache
   */
  protected static function object_cache_get($class_name, $key) {
    return messaging_static_cache_get($class_name, $key);
  }
  public static abstract function cache_set($key, $object);
  public static abstract function cache_get($key);

}

Members

Namesort descending Modifiers Type Description Overrides
Messaging_Cached_Object::cache_delete public function Delete object from cache 1
Messaging_Cached_Object::cache_get abstract public static function 1
Messaging_Cached_Object::cache_save public function Save object to cache 1
Messaging_Cached_Object::cache_set abstract public static function 1
Messaging_Cached_Object::delete function Delete from system and from static cache Overrides Messaging_Object::delete
Messaging_Cached_Object::insert public function Create object in database Overrides Messaging_Object::insert
Messaging_Cached_Object::object_cache_get protected static function Get value from static cache
Messaging_Cached_Object::object_cache_set protected static function Set value into static cache
Messaging_Cached_Object::object_load public static function Load object by unique key, may have static caching Overrides Messaging_Object::object_load
Messaging_Object::$deleted protected property
Messaging_Object::build abstract public static function 1
Messaging_Object::db_key abstract public static function
Messaging_Object::DB_KEY constant 2
Messaging_Object::db_load public static function Load object from DB
Messaging_Object::db_table abstract public static function
Messaging_Object::DB_TABLE constant 2
Messaging_Object::is_instance public function Check whether this object is an instance or just a template
Messaging_Object::key function Get unike id key
Messaging_Object::load abstract public static function 1
Messaging_Object::object_build public static function Build object from template
Messaging_Object::save public function Save to database
Messaging_Object::unserialize public function Unserialize after loading. It does nothing but can be overridden
Messaging_Object::update public function Update object in database
Messaging_Object::__construct public function Constructor, with predefined array of data 1
Messaging_Object::__set public function Magic function. Set protected properties