You are here

function ad_memcache_increment in Advertisement 5.2

Same name and namespace in other branches
  1. 5 cache/memcache/ad_cache_memcache.inc \ad_memcache_increment()
  2. 6 cache/memcache/ad_cache_memcache.inc \ad_memcache_increment()

Increment a numerical value in memcache.

1 call to ad_memcache_increment()
ad_cache_memcache_increment in cache/memcache/ad_cache_memcache.inc
Increment view counter in memcache.

File

cache/memcache/ad_cache_memcache.inc, line 286

Code

function ad_memcache_increment($key, $value = 1) {
  $memcache = ad_memcache_init();
  $rc = $memcache
    ->increment($key, $value);
  if ($rc === FALSE) {

    // We tried incrementing a counter that hasn't yet been initialized.
    $rc = $memcache
      ->set($key, $value);
    if ($rc === FALSE) {

      // Another process already initialized the counter, increment it.
      $rc = $memcache
        ->increment($key);
    }
  }
  return $rc;
}