You are here

function dmemcache_flush in Memcache API and Integration 7

Same name and namespace in other branches
  1. 5.2 dmemcache.inc \dmemcache_flush()
  2. 5 dmemcache.inc \dmemcache_flush()
  3. 6 dmemcache.inc \dmemcache_flush()

Flush all stored items.

Immediately invalidates all existing items. dmemcache_flush doesn't actually free any resources, it only marks all the items as expired, so occupied memory will be overwritten by new items.

Parameters

string $bin: The bin to flush. Note that this will flush all bins mapped to the same server as $bin. There is no way at this time to empty just one bin.

Return value

bool Returns TRUE on success or FALSE on failure.

1 call to dmemcache_flush()
drush_memcache_flush in ./memcache.drush.inc
Invalidate all items in specified bin.

File

./dmemcache.inc, line 591
A memcache API for Drupal.

Code

function dmemcache_flush($bin = 'cache', $mc = NULL) {
  $collect_stats = dmemcache_stats_init();
  $rc = FALSE;
  if ($mc || ($mc = dmemcache_object($bin))) {
    $rc = $mc
      ->flush();

    // If a composite call fails, we need to reset the authentication
    // for the whole mc object.
    if (empty($rc) && _dmemcache_reset_ascii_auth($mc)) {
      $mc
        ->flush();
    }
  }
  if ($collect_stats) {
    dmemcache_stats_write('flush', $bin, array(
      '' => $rc,
    ));
  }
  _dmemcache_write_debug('flush', $bin, '', $rc);
  return $rc;
}