Beispiel #1
0
 /**
  * @depends testCacheGetAll_1
  */
 public function testCacheGetAll_2($data)
 {
     sleep(2);
     $rs = $this->db->CacheGetAll(1, "SELECT *, UNIX_TIMESTAMP() AS timestamp,  FLOOR(0 + (RAND() * 1000)) AS rand FROM Country WHERE Continent = 'North America'");
     $this->assertNotEquals($data, $rs);
 }
Beispiel #2
0
 */
$disk = new DALMP\Cache(new DALMP\Cache\Disk());
/**
 * database instance
 */
$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';
$host = getenv('MYSQL_HOST') ?: '127.0.0.1';
$port = getenv('MYSQL_PORT') ?: '3306';
$db = new DALMP\Database("utf8://{$user}:{$password}@{$host}:{$port}/dalmp");
$sql = 'SELECT * FROM Country LIMIT 2';
/**
 * Cache for 5 minutes with key: mykey using memcache cache
 */
$db->useCache($memcache);
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$timer->setMark('memcache');
echo count($rs), PHP_EOL;
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$timer->setMark('memcache2');
echo count($rs), PHP_EOL;
/**
 * Cache for 5 minutes with key: mykey using redis cache
 */
$db->debug();
$db->useCache($redis);
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$timer->setMark('redis');
echo count($rs), PHP_EOL;
$rs = $db->CacheGetAll(300, $sql, 'mykey');
$db->debug('off');
Beispiel #3
0
<?php

require_once '../../MPLT.php';
$timer = new MPLT();
require_once '../../src/dalmp.php';
# ------------------------------------------------------------------------------
$user = getenv('MYSQL_USER') ?: 'root';
$password = getenv('MYSQL_PASS') ?: '';
$host = getenv('MYSQL_HOST') ?: '127.0.0.1';
$port = getenv('MYSQL_PORT') ?: '3306';
$DSN = "utf8://{$user}:{$password}@{$host}:{$port}/dalmp?redis:127.0.0.1:6379";
$db = new DALMP\Database($DSN);
$db->FetchMode('ASSOC');
$rs = $db->CacheGetAll('SELECT * FROM City');
print_r($rs);
# ------------------------------------------------------------------------------
echo PHP_EOL, str_repeat('-', 80), PHP_EOL;
echo str_repeat('-', 80), PHP_EOL, 'Time: ', $timer->getPageLoadTime(), ' - Memory: ', $timer->getMemoryUsage(1), PHP_EOL, str_repeat('-', 80), PHP_EOL;