Esempio n. 1
0
function cache_delete($key, $timeout = 0)
{
    $connection = cache_connect();
    $res = memcache_delete($connection, (string) $key, (int) $timeout);
    memcache_close($connection);
    return $res;
}
Esempio n. 2
0
function cache_set($key, $value)
{
    if (!cache_connect()) {
        return false;
    }
    $key = $GLOBALS['config']['service']['server'] . '/' . $key;
    $op = memcache_replace(object('memcache'), $key, $value, MEMCACHE_COMPRESSED, 60 * 60);
    if ($op == false) {
        memcache_add(object('memcache'), $key, $value, MEMCACHE_COMPRESSED, 60 * 60);
    }
}
Esempio n. 3
0
<?

ob_start();
if(cfg('memcache/enabled'))
{
  cache_connect();
  if(!object('memcache'))
  {
    banner('Could not connect to memcache server: '.cfg('memcache/server'));
  }
  else
  {
    $stats = object('memcache')->getStats(); 
    print('<div class="smallwin banner">');
    print('Memcached Version: '.$stats['version'].', ');     
    print('Current Connections: '.$stats['curr_connections'].'<br/>');     
    print('Cache Size: '.number_format($stats['limit_maxbytes'] / (1024*1024), 2).' MB total, '.number_format(($stats['limit_maxbytes']-$stats['bytes']) / (1024*1024), 2).' MB free<br/>');     
    print('Hits: '.ceil($stats['get_hits'] / (1)).', Misses: '.ceil($stats['get_misses'] / (1)).', Evictions: '.ceil($stats['evictions'] / 1).'<br/>');     
    print('</div>');
  }
}
if($GLOBALS['errors']['memcache'] != '')
{
  ?><div class="fail banner">
    Error: <?php 
echo $GLOBALS['errors']['memcache'];
?>
  </div><? 
}
$memcache_status = ob_get_clean();