コード例 #1
0
 public function __construct(&$config, &$db_assertor)
 {
     parent::__construct($config, $db_assertor);
     if (!empty($config['Cache']['memcacheprefix'])) {
         $this->prefix =& $config['Cache']['memcacheprefix'];
     }
     $this->memcache = vB_Memcache::instance();
 }
コード例 #2
0
 public static function instance()
 {
     if (!isset(self::$instance)) {
         if (class_exists('Memcached', FALSE)) {
             $class = 'vB_Memcached';
         } else {
             if (class_exists('Memcache', FALSE)) {
                 $class = __CLASS__;
             } else {
                 throw new Exception('Memcached is not installed');
             }
         }
         self::$instance = new $class();
         self::$instance->config = vB::getConfig();
     }
     return self::$instance;
 }
コード例 #3
0
 /**
  * Constructor protected to enforce singleton use.
  * @see instance()
  */
 protected function __construct($cachetype)
 {
     parent::__construct($cachetype);
     $this->memcached = vB_Memcache::instance();
     $check = $this->memcached->connect();
     if ($check === 3) {
         trigger_error('Unable to connect to memcache server', E_USER_ERROR);
     }
     $this->expiration = 48 * 60 * 60;
     // two days
     $this->timeNow = vB::getRequest()->getTimeNow();
     //get the memcache prefix.
     $config = vB::getConfig();
     if (empty($config['Cache']['memcacheprefix'])) {
         $this->prefix = $config['Database']['tableprefix'];
     } else {
         $this->prefix = $config['Cache']['memcacheprefix'];
     }
 }