public function CacheBackendInterface::set

Stores data in the persistent cache.

Parameters

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

mixed $data: The data to store in the cache.

int $expire: One of the following values:

  • CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
  • A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.

array $tags: An array of tags to be stored with the cache item. These should normally identify objects used to build the cache item, which should trigger cache invalidation when updated. For example if a cached item represents a node, both the node ID and the author's user ID might be passed in as tags. For example array('node' => array(123), 'user' => array(92)).

See also

Drupal\Core\Cache\CacheBackendInterface::get()

Drupal\Core\Cache\CacheBackendInterface::getMultiple()

4 methods override CacheBackendInterface::set()
BackendChain::set in drupal/core/lib/Drupal/Core/Cache/BackendChain.php
Implements Drupal\Core\Cache\CacheBackendInterface::set().
DatabaseBackend::set in drupal/core/lib/Drupal/Core/Cache/DatabaseBackend.php
Implements Drupal\Core\Cache\CacheBackendInterface::set().
MemoryBackend::set in drupal/core/lib/Drupal/Core/Cache/MemoryBackend.php
Implements Drupal\Core\Cache\CacheBackendInterface::set().
NullBackend::set in drupal/core/lib/Drupal/Core/Cache/NullBackend.php
Implements Drupal\Core\Cache\CacheBackendInterface::set().

File

drupal/core/lib/Drupal/Core/Cache/CacheBackendInterface.php, line 146
Definition of Drupal\Core\Cache\CacheBackendInterface.

Class

CacheBackendInterface
Defines an interface for cache implementations.

Namespace

Drupal\Core\Cache

Code

public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array());