You are here

function ad_cache_memcache_increment in Advertisement 5.2

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

Increment view counter in memcache.

1 call to ad_cache_memcache_increment()
ad_cache_memcache in cache/memcache/ad_cache_memcache.inc
Called by adserve.inc, display an ad from memcache.

File

cache/memcache/ad_cache_memcache.inc, line 187

Code

function ad_cache_memcache_increment($action, $aid, $group, $hostid, $ad = array()) {
  static $timestamp = NULL;
  _debug_echo("Memcache: increment action({$action}) aid({$aid}) group({$group}) hostid({$hostid}).");
  if ($aid && !is_object($ad)) {
    _debug_echo("Invalid ad id: {$aid}.");
    return 0;
  }
  if (is_null($timestamp)) {
    $timestamp = date('YmdH');
  }
  $counters = ad_memcache_get("ad-counters-{$aid}");
  $update = TRUE;
  if (!is_array($counters) || !isset($counters["{$action}:{$group}:{$hostid}:{$timestamp}"])) {
    _debug_echo("Memcache: adding map: action({$action}) aid({$aid}) group({$group}) hostid({$hostid}) timestamp({$timestamp})");
    ad_memcache_increment_map($action, $aid, $group, $hostid, $timestamp);
  }
  $rc = ad_memcache_increment("ad-{$action}-{$aid}-{$group}-{$hostid}-{$timestamp}");
  _debug_echo("Memcache: incrementing ad-{$action}-{$aid}-{$group}-{$hostid}-{$timestamp} ({$rc})");
}