You are here

public function CacheRawBackendInterface::set in Supercache 8

Same name and namespace in other branches
  1. 2.0.x src/Cache/CacheRawBackendInterface.php \Drupal\supercache\Cache\CacheRawBackendInterface::set()

Stores data in the persistent cache.

Core cache implementations set the created time on cache item with microtime(TRUE) rather than REQUEST_TIME_FLOAT, because the created time of cache items should match when they are created, not when the request started. Apart from being more accurate, this increases the chance an item will legitimately be considered valid.

Parameters

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

mixed $data: The data to store in the cache. Some storage engines only allow objects up to a maximum of 1MB in size to be stored by default. When caching large arrays or similar, take care to ensure $data does not exceed this size.

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, that is, 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.

See also

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

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

3 methods override CacheRawBackendInterface::set()
ApcuRawBackend::set in src/Cache/ApcuRawBackend.php
Stores data in the persistent cache.
ChainedFastRawBackend::set in src/Cache/ChainedFastRawBackend.php
Stores data in the persistent cache.
DatabaseRawBackend::set in src/Cache/DatabaseRawBackend.php
Stores data in the persistent cache.

File

src/Cache/CacheRawBackendInterface.php, line 84
Contains \Drupal\supercache\Cache\CacheRawBackendInterface.

Class

CacheRawBackendInterface
Defines an interface for cache implementations.

Namespace

Drupal\supercache\Cache

Code

public function set($cid, $data, $expire = CacheRawBackendInterface::CACHE_PERMANENT);