Beispiel #1
0
 /**
  * Check if memcache is available
  *
  * @param array $servers
  * @return boolean
  */
 function is_memcache_available($servers)
 {
     static $results = array();
     $key = md5(implode('', $servers));
     if (!isset($results[$key])) {
         w3_require_once(W3TC_LIB_W3_DIR . '/Cache/Memcached.php');
         @($memcached = new W3_Cache_Memcached(array('servers' => $servers, 'persistant' => false)));
         $test_string = sprintf('test_' . md5(time()));
         $test_value = array('content' => $test_string);
         $memcached->set($test_string, $test_value, 60);
         $test_value = $memcached->get($test_string);
         $results[$key] = $test_value['content'] == $test_string;
     }
     return $results[$key];
 }