You are here

public function CacheObjectAPIWrapper::set in Cache Object API 7

Stores data in the persistent cache.

Parameters

$cid: The cache ID of the data to store.

$data: The data to store in the cache. Complex data types will be automatically serialized before insertion. Strings will be stored as plain text and not serialized.

$expire: One of the following values:

  • CACHE_PERMANENT: Indicates that the item should never be removed unless explicitly told to using cache_clear_all() with a cache ID.
  • CACHE_TEMPORARY: Indicates that the item should be removed at the next general cache wipe.
  • A Unix timestamp: Indicates that the item should be kept at least until the given time, after which it behaves like CACHE_TEMPORARY.

Overrides DrupalCacheInterface::set

File

./cacheobject.inc, line 99
Provides Cache Object API wrapper class.

Class

CacheObjectAPIWrapper
Provides a cache class exposing hooks operating on objects before they are stored to and after they were received from the cache.

Code

public function set($cid, $data, $expire = CACHE_PERMANENT) {
  $object = (object) array(
    'cid' => $cid,
    'data' => $data,
    'expire' => $expire,
  );
  $save = module_invoke_all('cacheobject_presave', $object, $cid, $this->bin);
  if (!$this
    ->checkResult($save)) {
    return;
  }
  $this->delegate
    ->set($object->cid, $object->data, $object->expire);
}