start() 공개 메소드

Calls extraSub().
public start ( CacheKey $k, string $lifetime = null, boolean $print = true, boolean $fail = false ) : boolean | string
$k CacheKey
$lifetime string The lifetime, in seconds
$print boolean if True echoes the data
$fail boolean if false throws an exception if something happens, such as not cached
리턴 boolean | string True if cached
예제 #1
0
 private function _startNested(CacheAbstract $cache)
 {
     $expected = ["first level", "second level 1", "second level 2", "second level 3"];
     $i = 0;
     $data = '';
     if (!($data = $cache->start(new CacheKey('startnested', 'first', 0), null, false))) {
         $this->assertTrue(true);
         echo $expected[$i++];
         if (!$cache->start(new CacheKey('startnested', 'second', $i), null, false)) {
             echo $expected[$i++];
             if (!$cache->start(new CacheKey('startnested', 'second', $i), null, false)) {
                 echo $expected[$i++];
                 if (!$cache->start(new CacheKey('startnested', 'second', $i), null, false)) {
                     echo $expected[$i++];
                     $cache->end();
                 }
                 $cache->end();
             }
             $cache->end();
         }
         $data = $cache->end(false);
     } else {
         $this->assertTrue(false);
     }
     $this->assertEquals(implode('', $expected), $data);
 }
예제 #2
0
 protected function _startcallback(CacheAbstract $cache)
 {
     $key = new CacheKey("startcallback", 1);
     $cache->clean($key);
     $this->assertFalse($cache->start($key));
     echo "something ";
     $this->assertTrue($cache->appendCallback('callbackTesterStart'));
     echo " otherthing";
     $output = $cache->end(false);
     $this->assertContains(CALLBACKVALUE, $output);
     // run again, we should have another value
     $second = $cache->start($key, null, false);
     $this->assertNotFalse($second);
     $this->assertContains(CALLBACKVALUE, $second);
     $this->assertNotEquals($second, $output);
 }
예제 #3
0
 public function _dependencies(CacheAbstract $cache)
 {
     $cache->start('parent', 1);
     $cache->addDependency();
     echo 'parent start/';
     $this->assertFalse($cache->appendCallback('nawreanaweroi'));
     // invalid
     $cache->appendCallback('cacheCallback');
     $cache->start('child', 2);
     echo '|child first|';
     $cache->end(false);
     echo 'parent end/';
     $cache->end(false);
 }