You are here

function performance_prune_memcache in Performance Logging and Monitoring 7

Same name and namespace in other branches
  1. 6 performance.module \performance_prune_memcache()

Helper function to cleanup Memcache data.

See also

performance_data_stores()

File

./performance.module, line 667
Logs detailed and/or summary page generation time and memory consumption for page requests. Copyright Khalid Baheyeldin 2008 of http://2bits.com

Code

function performance_prune_memcache($timestamp = 0, $threshold = 0) {
  if ($keys_cache = cache_get(PERFORMANCE_KEY, PERFORMANCE_MEMCACHE_BIN)) {
    if ($keys_cache->data) {
      foreach ($keys_cache->data as $key => $v) {
        $cache = cache_get($key, PERFORMANCE_MEMCACHE_BIN);
        if ($cache->created <= $timestamp || $threshold && $cache->data['num_accesses'] <= $threshold) {
          cache_clear_all($key, PERFORMANCE_MEMCACHE_BIN);
        }
      }
    }
  }
}