コード例 #1
0
ファイル: AccessTest.php プロジェクト: ming-hai/XoopsCore
 /**
  * @covers Xoops\Core\Cache\Access::clear
  * @covers Xoops\Core\Cache\Access::write
  * @covers Xoops\Core\Cache\Access::read
  */
 public function testClear()
 {
     $key = 'offhand/name';
     $value = 'Fred';
     $ret = $this->object->write($key, $value);
     $this->assertTrue($ret);
     $ret = $this->object->read($key);
     $this->assertSame($ret, $value);
     $ret = $this->object->clear();
     $this->assertTrue($ret);
     $ret = $this->object->read($key);
     $this->assertFalse($ret);
 }
コード例 #2
0
ファイル: Cache.php プロジェクト: ming-hai/XoopsCore
 /**
  * cache block wrapper
  *
  * If the cache read for $key is a miss, call the $regenFunction to update it.
  * With the PRECOMPUTE strategy, it  will trigger a miss on a read on one caller
  * before the cache expires, so it will be done in advance.
  *
  * @param string|string[]   $cacheKey      Identifier for the cache item
  * @param callable          $regenFunction function to generate cached content
  * @param int|DateTime|null $ttl           time to live, number ofseconds as integer,
  *                                         DateTime to expire at a specific time,
  *                                         or null for default
  * @param mixed          ...$args          variable argument list for $regenFunction
  *
  * @return mixed
  */
 public function cacheRead($cacheKey, $regenFunction, $ttl = null, $args = null)
 {
     return $this->cache->cacheRead($this->prefix($cacheKey), $regenFunction, $ttl, $args);
 }