You are here

function ad_cache_memcache_requirements in Advertisement 5.2

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

@file A plug in for the ad.module, integrating the ad module with memcache.

Copyright (c) 2008. Jeremy Andrews <jeremy@tag1consulting.com>.

3 calls to ad_cache_memcache_requirements()
ad_cache_memcache_build in cache/memcache/ad_cache_memcache.module
Caches ad information into memory.
ad_cache_memcache_sync in cache/memcache/ad_cache_memcache.module
Load advertisements into memory.
ad_cache_memcache_sync_ad in cache/memcache/ad_cache_memcache.module
Syncronize counts for given advertisement with database.

File

cache/memcache/ad_cache_memcache.module, line 11
A plug in for the ad.module, integrating the ad module with memcache.

Code

function ad_cache_memcache_requirements($phase = NULL) {

  // Connect to memcached so we can retrieve its version.
  if (function_exists('memcache_add_server')) {
    require_once drupal_get_path('module', 'ad_cache_memcache') . '/ad_cache_memcache.inc';
    $memcache = ad_memcache_init();

    // Retrieve the version of memcache.
    if (function_exists('memcache_get_version')) {
      $severity = REQUIREMENT_OK;
      $value = memcache_get_version($memcache);
    }
    else {
      $severity = REQUIREMENT_ERROR;
      $value = t('Memcache installation not valid, %function not found.', array(
        '%function' => 'memcache_get_version',
      ));
    }
  }
  else {
    $severity = REQUIREMENT_ERROR;
    $value = t('Memcache is not installed, %function not found.', array(
      '%function' => 'memcache_add_server',
    ));
  }
  if ($phase) {
    return array(
      'memcache' => array(
        'title' => t('Memcache'),
        'value' => $value,
        'severity' => $severity,
      ),
    );
  }
  else {
    if ($severity == REQUIREMENT_OK) {
      return TRUE;
    }
    else {
      return $value;
    }
  }
}