Beispiel #1
0
$timer->setMark('redis2');
echo count($rs), PHP_EOL;
/**
 * Cache for 5 minutes with key: mykey using disk cache
 */
$db->useCache($disk);
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$timer->setMark('disk');
echo count($rs), PHP_EOL;
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$timer->setMark('disk2');
echo count($rs), PHP_EOL;
/**
 * flush the query $sql with key on DISK cache instance
 */
$db->CacheFlush($sql, 'mykey');
/**
 * flush the query $sql with key only on Redis cache instance
 */
$db->useCache($redis);
$db->CacheFlush($sql, 'mykey');
/**
 * flush all the cache in all instances
 */
foreach (array('memcache', 'redis', 'disk') as $val) {
    $db->useCache(${$val});
    $db->CacheFlush($sql, 'mykey');
}
# ------------------------------------------------------------------------------
echo PHP_EOL, str_repeat('-', 80), PHP_EOL;
$timer->printMarks();
Beispiel #2
0
/**
 * Cache for 1 hour (default), group C
 */
$rs = $db->CachePGetAll('SELECT * FROM Country WHERE Population <= ?', 100000, 'group:C');
echo count($rs), PHP_EOL;
$timer->setMark('default');
/**
 * lazy connection test query DB only when needed
 */
$db->debug();
$db->closeConnection();
/**
 * Cache for 5 minutes, group A
 */
$rs = $db->CachePGetAll('SELECT * FROM Country WHERE Region = ?', 'Caribbean');
echo count($rs), PHP_EOL;
$timer->setMark('lazy');
/**
 * flush only group A
 */
$db->CacheFlush('group:A');
/**
 * Cache for 5 minutes, group A
 */
$rs = $db->CachePGetAll(300, 'SELECT * FROM Country WHERE Region = ?', 'Caribbean', 'group:A');
echo count($rs), PHP_EOL;
$timer->setMark('connect');
# ------------------------------------------------------------------------------
echo PHP_EOL, str_repeat('-', 80), PHP_EOL;
$timer->printMarks();
echo str_repeat('-', 80), PHP_EOL, 'Time: ', $timer->getPageLoadTime(), ' - Memory: ', $timer->getMemoryUsage(1), PHP_EOL, str_repeat('-', 80), PHP_EOL;
Beispiel #3
0
 public function testCacheFlushEnd()
 {
     $rs = $this->db->CacheFlush();
     $this->assertTrue($rs);
 }