Example #1
0
 /**
  * @depends testMSet
  * @depends testMSetNX
  */
 public function testMGet()
 {
     $cache = \linkcache\Cache::getInstance($this->cacheDriver);
     $this->assertArraySubset(['mset1' => '1', 'mset2' => [1, 2, 3], 'mset3' => '3'], $cache->mGet(['mset1', 'mset2', 'mset3']), true);
     $this->assertArraySubset(['mset1' => '1', 'mset2' => [1, 2, 3], 'mset4' => false], $cache->mGet(['mset1', 'mset2', 'mset4']), true);
     $this->assertArraySubset(['msetnx1' => '1', 'msetnx2' => '2', 'msetnx3' => '3'], $cache->mGet(['msetnx1', 'msetnx2', 'msetnx3']), true);
 }
Example #2
0
 /**
  * @depends testMSet
  * @depends testMSetNX
  * @depends testMDel
  */
 public function testMHas()
 {
     $cache = \linkcache\Cache::getInstance($this->cacheDriver);
     $this->assertArraySubset(['mset1', 'mset3'], $cache->mHas(['mset1', 'mset2', 'mset3', 'mset4']), true);
     $this->assertArraySubset([], $cache->mHas(['msetnx4', 'msetnx5']), true);
     $this->assertArraySubset(['msetnx1'], $cache->mHas(['msetnx1', 'msetnx2']), true);
 }
Example #3
0
 /**
  * 返回定义为fallback的Cache实例
  * @return Cache
  */
 public function backup()
 {
     $fallback = !empty($this->fallback) ? $this->fallback : 'files';
     return \linkcache\Cache::getInstance($fallback);
 }
Example #4
0
<?php

require_once '../autoload.php';
$cache = \linkcache\Cache::getInstance();
$cache->set('sayhi', 'Hello world!');
echo $cache->get('sayhi');