Cachearium\CacheAbstract::start PHP Method

start() public method

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
return boolean | string True if cached
    public function start(CacheKey $k, $lifetime = null, $print = true, $fail = false)
    {
        $this->extraSub($k->sub);
        return $this->recursiveStart($k, $lifetime, $print, $fail);
    }

Usage Example

 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);
 }
All Usage Examples Of Cachearium\CacheAbstract::start