It's a very simple implementation. It's reasonably inneficient because it a 3-level array, but it does invalidation correctly. This is useful for data that is loaded many times in one execution but which may change constantly, or in servers that have no external cache support for a quick speedup.
Inheritance: extends Cachearium\CacheAbstract
 public function teststartCallbackRAM()
 {
     $cache = CacheRAM::singleton();
     if ($cache->isEnabled()) {
         $this->_startcallback($cache);
     }
 }
示例#2
0
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
<?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
 /**
  * Clear prefetched data. This is rarely useful.
  */
 public function prefetchClear()
 {
     parent::clear();
 }
示例#7
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();
         }
     }
 }
示例#8
0
 public function testClearRAM()
 {
     $cache = CacheRAM::singleton();
     $this->setBigClean($cache);
 }
 public function testStartNested()
 {
     $cache = CacheRAM::singleton();
     if ($cache->isEnabled()) {
         $this->_startNested($cache);
     }
 }