You are here

public function DrupalMemcachedBase::set in Memcache Storage 8

Set the cache to the memcached.

Parameters

$key: Cache key string.

$value: Cache value.

int $expiration: Timestamp of cache expiration date. If cache is permanent - then the value is 0.

string $cache_bin: Name of the cache bin.

Overrides DrupalMemcachedInterface::set

2 calls to DrupalMemcachedBase::set()
DrupalMemcachedBase::getBinIndex in src/DrupalMemcachedBase.php
Returns cache bin index. This index is part of memcache key and changes if cache bin should be cleared.
DrupalMemcachedBase::increaseBinIndex in src/DrupalMemcachedBase.php
Increase cache bin index. This operation changes all memcache keys in the specified cache bin, so we fake the cache flush operation.

File

src/DrupalMemcachedBase.php, line 186

Class

DrupalMemcachedBase
Class DrupalMemcachedBase

Namespace

Drupal\memcache_storage

Code

public function set($key, $value, $expiration = 0, $cache_bin = '') {

  // Simply prepate the object and execute multiple set method.
  $item = new \stdClass();
  $item->cid = $key;
  $item->expire = $expiration;
  $item->data = $value;
  $this
    ->setMulti([
    $item,
  ], $cache_bin);
}