function MemoryCache::set

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php \Drupal\Core\Cache\MemoryCache\MemoryCache::set()
  2. 8.9.x core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php \Drupal\Core\Cache\MemoryCache\MemoryCache::set()
  3. 11.x core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php \Drupal\Core\Cache\MemoryCache\MemoryCache::set()

Overrides MemoryBackend::set

File

core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php, line 50

Class

MemoryCache
Defines a memory cache implementation.

Namespace

Drupal\Core\Cache\MemoryCache

Code

public function set($cid, $data, $expire = MemoryCacheInterface::CACHE_PERMANENT, array $tags = []) {
  assert(Inspector::assertAllStrings($tags), 'Cache tags must be strings.');
  $tags = array_unique($tags);
  $this->cache[$cid] = (object) [
    'cid' => $cid,
    'data' => $data,
    'created' => $this->time
      ->getRequestTime(),
    'expire' => $expire,
    'tags' => $tags,
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.