Пример #1
0
 function testCache()
 {
     $this->cache->purge();
     self::createSQL();
     $prepSQL = 'INSERT INTO `test_table` VALUES (?), (?), (?)';
     $prepParams = [1, 2, 3];
     $agSQL = 'SELECT SUM(`key0`) FROM `test_table`';
     $agSettings = [MySQL::V_CACHE => true, MySQL::V_TIME => 20];
     PhuGlobal::$mysql->prepQuery($prepSQL, $prepParams);
     $agg = PhuGlobal::$mysql->aggregate($agSQL, null, $agSettings);
     $lastHash = PhuGlobal::$mysql->getLastHash();
     $getAll = $this->cache->getAll();
     $get = $this->cache->get($lastHash);
     $this->assertArrayHasKey($lastHash, $getAll, _unit_dump(['lastHash' => $lastHash, 'getAll' => $getAll]));
     $this->assertEquals($agg, $get, _unit_dump(['aggregate' => $agg, 'get' => $get]));
     self::deleteSQL();
 }
Пример #2
0
 /**
  * Instantiates the class
  *
  * @author Art <*****@*****.**>
  *
  * @param boolean $initDefaultServer Whether to add a server on construct
  */
 function __construct($initDefaultServer = true)
 {
     $this->client = new Redis();
     if ($initDefaultServer) {
         $this->addServer();
     }
     parent::__construct();
     \Log::debug('RedisWrapper instantiated.');
 }
Пример #3
0
 /**
  * Instantiates the class
  *
  * @author Art <*****@*****.**>
  *
  * @param boolean $initDefaultServer Whether to add a server on construct
  */
 function __construct($initDefaultServer = true)
 {
     if (self::$loaded === null) {
         if (class_exists('\\Memcached', false)) {
             self::$loaded = self::CLASS_MEMCACHED;
         } elseif (class_exists('\\Memcache')) {
             self::$loaded = self::CLASS_MEMCACHE;
         } else {
             self::$loaded = false;
         }
     }
     if (self::$loaded !== null) {
         $this->client = self::$loaded === self::CLASS_MEMCACHED ? new Memcached() : new Memcache();
         if ($initDefaultServer) {
             $this->addServer();
         }
     } else {
         phpWarning('Memcached extension not loaded - caching ' . 'functions will not work');
     }
     parent::__construct();
     \Log::debug(self::$loaded ? 'Loaded MemcachedWrapper' : 'MemcachedWrapper not loaded: extension unavailable');
 }