/**
  * Konstruktor statyczny
  */
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         $className = __CLASS__;
         self::$instance = new $className();
     }
     return self::$instance;
 }
 public function __construct($ttl = 0)
 {
     parent::__construct($ttl);
     if (empty(self::$_server)) {
         $mt = MT::get_instance();
         $servers = $mt->config('MemcachedServers');
         if (!empty($servers)) {
             if (extension_loaded('memcache')) {
                 self::$_server = new Memcache();
                 $this->connect($servers);
             } else {
                 require_once 'class.exception.php';
                 throw new MTException("Cannot load memcached extension.");
             }
         } else {
             require_once 'class.exception.php';
             throw new MTException("Cannot load memcached extension.");
         }
     }
 }
Example #3
0
 public function supported()
 {
     // report the old Memcache (withoud "d") only support when the new one is not present
     $memcached = new CacheMemcached();
     return !$memcached->supported() && class_exists('Memcache', false);
 }
Example #4
0
 public function __construct()
 {
     $this->dataStore = \CacheMemcached::factory();
     $this->dataStatistics = new \CacheApc();
 }
Example #5
0
 /**
  * Returns a Memcache instance. Will try certain fallbacks to get a working implementation 
  * 
  * @return CacheInterface
  */
 public static function factory()
 {
     $memcached = new CacheMemcached();
     if ($memcached->supported()) {
         return $memcached;
     } else {
         $fallback = new CacheMemcache();
         if ($fallback->supported()) {
             return $fallback;
         }
     }
     throw new Exception('Missing memcached php-extension');
 }