You are here

final protected function DrupalMemcachedBase::increaseBinIndex in Memcache Storage 8

Increase cache bin index. This operation changes all memcache keys in the specified cache bin, so we fake the cache flush operation.

Parameters

$cache_bin: Name of the cache bin.

1 call to DrupalMemcachedBase::increaseBinIndex()
DrupalMemcachedBase::flush in src/DrupalMemcachedBase.php
Reset the cache for the entire cache bin.

File

src/DrupalMemcachedBase.php, line 266

Class

DrupalMemcachedBase
Class DrupalMemcachedBase

Namespace

Drupal\memcache_storage

Code

protected final function increaseBinIndex($cache_bin) {

  // We force reload the data from memcached to avoid race conditions with
  // other threads who could already increase bin index for the cache bin.
  // TODO: Lock this operation to avoid race conditions?
  $cache = $this
    ->get('memcache_storage_bin_indexes');
  if (empty($cache->data)) {
    $this->bin_indexes[$cache_bin] = 1;
  }
  else {
    $this->bin_indexes = $cache->data;
    $current_index = !empty($cache->data[$cache_bin]) ? $cache->data[$cache_bin] : 0;
    $this->bin_indexes[$cache_bin] = ++$current_index;
  }
  $this
    ->set('memcache_storage_bin_indexes', $this->bin_indexes, 0);
}