function MemoryBackend::set

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

Overrides CacheBackendInterface::set

2 calls to MemoryBackend::set()
MemoryBackend::setMultiple in core/lib/Drupal/Core/Cache/MemoryBackend.php
MemoryCounterBackend::set in core/lib/Drupal/Core/Cache/MemoryCounterBackend.php
2 methods override MemoryBackend::set()
MemoryCache::set in core/lib/Drupal/Core/Cache/MemoryCache/MemoryCache.php
MemoryCounterBackend::set in core/lib/Drupal/Core/Cache/MemoryCounterBackend.php

File

core/lib/Drupal/Core/Cache/MemoryBackend.php, line 116

Class

MemoryBackend
Defines a memory cache implementation.

Namespace

Drupal\Core\Cache

Code

public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {
    assert(Inspector::assertAllStrings($tags), 'Cache Tags must be strings.');
    $tags = array_unique($tags);
    // Sort the cache tags so that they are stored consistently in the database.
    sort($tags);
    $this->cache[$cid] = (object) [
        'cid' => $cid,
        'data' => serialize($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.