Cachearium\CacheAbstract::getP PHP Method

getP() public method

Same as get(), but expanded parameters.
See also: getK
public getP ( string $base, string $id, mixed $sub = null ) : mixed
$base string
$id string
$sub mixed
return mixed
    public function getP($base, $id, $sub = null)
    {
        return $this->get(new CacheKey($base, $id, $sub));
    }

Usage Example

Example #1
0
 private function setBigClear(CacheAbstract $cache)
 {
     $id = '2';
     $base = 'bigclean';
     $otherid = '3';
     $otherbase = 'bigfoo';
     $retval = $cache->storeP(111, $base, $id, 'a');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(222, $base, $id, 'b');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(333, $base, $otherid, 'a');
     $this->assertEquals(true, $retval);
     $retval = $cache->storeP(444, $otherbase, $otherid, 'a');
     $this->assertEquals(true, $retval);
     $data = $cache->getP($base, $id, 'a');
     $this->assertEquals(111, $data);
     $data = $cache->getP($base, $id, 'b');
     $this->assertEquals(222, $data);
     $data = $cache->getP($base, $otherid, 'a');
     $this->assertEquals(333, $data);
     $data = $cache->getP($otherbase, $otherid, 'a');
     $this->assertEquals(444, $data);
     $cache->clear();
     try {
         $data = $cache->getP($base, $id, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($base, $id, 'b');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($base, $otherid, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
     try {
         $data = $cache->getP($otherbase, $otherid, 'a');
         $this->fail();
     } catch (Cachearium\Exceptions\NotCachedException $e) {
         $this->assertTrue(true);
     }
 }