enabled() public static méthode

Determines if the Memcached extension has been installed.
public static enabled ( ) : boolean
Résultat boolean Returns `true` if the `Memcached` extension is installed and enabled, `false` otherwise.
 public function testEnabled()
 {
     $this->assertTrue(Memcache::enabled());
 }
Exemple #2
0
/**
 * This file creates a default cache configuration using the most optimized adapter available, and
 * uses it to provide default caching for high-overhead operations.
 */
use lithium\storage\Cache;
use lithium\core\Libraries;
use lithium\action\Dispatcher;
use lithium\storage\cache\adapter\Memcache;
use lithium\storage\cache\adapter\File;
if (PHP_SAPI === 'cli') {
    return;
}
/**
 * If APC is not available and the cache directory is not writeable, bail out.
 */
if (!($memcacheEnabled = Memcache::enabled()) && !is_writable(LITHIUM_APP_PATH . '/resources/tmp/cache')) {
    return;
}
if ($memcacheEnabled && USE_MEMCACHED === true) {
    Cache::config(array('default' => array('adapter' => 'Memcache', 'host' => MEMCACHED_SERVER)));
} else {
    Cache::config(array('default' => array('adapter' => 'File')));
}
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    if ($cache = Cache::read('default', 'core.libraries')) {
        $cache = (array) unserialize($cache) + Libraries::cache();
        Libraries::cache($cache);
    }
    $result = $chain->next($self, $params, $chain);
    if ($cache != Libraries::cache()) {
        Cache::write('default', 'core.libraries', serialize(Libraries::cache()), '+1 day');