You are here

function ad_cache_memcache_hook in Advertisement 6

Same name and namespace in other branches
  1. 5.2 cache/memcache/ad_cache_memcache.inc \ad_cache_memcache_hook()
  2. 5 cache/memcache/ad_cache_memcache.inc \ad_cache_memcache_hook()
3 calls to ad_cache_memcache_hook()
ad_cache_memcache in cache/memcache/ad_cache_memcache.inc
Called by adserve.inc, display an ad from memcache.
ad_cache_memcache_adserve_exit_text in cache/memcache/ad_cache_memcache.inc
Allow external exit text.
ad_cache_memcache_adserve_select in cache/memcache/ad_cache_memcache.inc
Allow external ad selection logic.

File

cache/memcache/ad_cache_memcache.inc, line 111
Memcache include.

Code

function ad_cache_memcache_hook(&$cache, $hook, $func) {
  if (empty($cache)) {
    _debug_echo('Memcache: retrieving hook info from cache.');
    $cache = ad_memcache_get('ad-cache-hook');
  }
  $include_func = NULL;
  if (is_array($cache) && !empty($cache)) {
    $include_file = adserve_variable('root_dir') . '/' . $cache[$hook];
    if (file_exists($include_file) && is_file($include_file)) {
      _debug_echo("Memcache: including external file: '{$include_file}'.");
      include_once $include_file;
    }
    else {
      if (is_file($include_file)) {
        _debug_echo("Memcache: unable to find external file: '{$include_file}'.");
      }
      else {
        _debug_echo('Memcache: no include file defined in cache.');
      }
    }
    $include_func = $cache[$func];
    if ($include_func) {
      _debug_echo("Memcache: returning requested func({$func}): '{$include_func}'.");
    }
  }
  return $include_func;
}