singleton() public static method

Cache constructor (this is a singleton).
public static singleton ( ) : CacheRAM
return CacheRAM The cache singleton.
コード例 #1
0
 public function teststartCallbackRAM()
 {
     $cache = CacheRAM::singleton();
     if ($cache->isEnabled()) {
         $this->_startcallback($cache);
     }
 }
コード例 #2
0
ファイル: basic.php プロジェクト: corollarium/cachearium
function someCachedStuff()
{
    $cache = CacheRAM::singleton();
    if (!$cache->start(new CacheKey("outside", 1))) {
        // not cached
        echo '<div>';
        echo "some random bla bla" . rand();
        echo '</div>';
        $cache->end();
    }
}
コード例 #3
0
ファイル: debugprobe.php プロジェクト: corollarium/cachearium
<?php

require_once __DIR__ . '/../src/Cache.php';
use Cachearium\Backend\CacheRAM;
use Cachearium\CacheKey;
$cache = CacheRAM::singleton();
// turn on page debugging on
$cache::$debugOnPage = true;
$cache->setLog(true);
?>
<html>
<head>
<title>Cachearium debug probe</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<style>
<?php 
$cache->cssDebug();
?>
body {
	margin-top: 80px;
}

.bigoutsidediv {
	width: 100%;
}
.mediumdiv {
	width: 96%;
	margin: 2%;
	border: 1px solid blue;
	height: 100px;
}
コード例 #4
0
 public function testNothing()
 {
     CacheRAM::singleton();
 }
コード例 #5
0
 public function testClearAll()
 {
     $cacheKey = new CacheKey('test', 1);
     $cacheData = new CacheData($cacheKey, 'test');
     $caches = [CacheRAM::singleton(), CacheFilesystem::singleton()];
     if (CacheMemcached::hasMemcachedExt()) {
         $caches[] = CacheMemcached::singleton();
     }
     foreach ($caches as $cacheInst) {
         $cacheInst->enable()->storeData($cacheData);
         $retrievedData = $cacheInst->getData($cacheKey);
         $this->assertEquals($cacheData->getFirstData(), $retrievedData->getFirstData());
     }
     CacheAbstract::clearAll();
     foreach ($caches as $cacheInst) {
         try {
             $retrievedData = $cacheInst->getData($cacheKey);
             $this->fail('Cache should be empty after a clearAll call !');
         } catch (\Cachearium\Exceptions\NotCachedException $e) {
             $this->assertTrue(true, 'All cache was cleaned');
         }
     }
 }
コード例 #6
0
 /**
  * Clears all cache classes.
  * @codeCoverageIgnore
  */
 public static function clearAll()
 {
     $caches = [\Cachearium\Backend\CacheRAM::singleton(), \Cachearium\Backend\CacheFilesystem::singleton(), \Cachearium\Backend\CacheMemcached::singleton()];
     foreach ($caches as $cacheInst) {
         if ($cacheInst->isEnabled()) {
             $cacheInst->clear();
         }
     }
 }
コード例 #7
0
ファイル: CacheTest.php プロジェクト: corollarium/cachearium
 public function testClearRAM()
 {
     $cache = CacheRAM::singleton();
     $this->setBigClean($cache);
 }
コード例 #8
0
 public function testStartNested()
 {
     $cache = CacheRAM::singleton();
     if ($cache->isEnabled()) {
         $this->_startNested($cache);
     }
 }