die if caching modules are missing, don't silently fall back to NoCache
This commit is contained in:
parent
4e5af70093
commit
2f557326df
@ -399,7 +399,6 @@ class MemcachedCache implements CacheEngine {
|
|||||||
*/
|
*/
|
||||||
public function get($key) {
|
public function get($key) {
|
||||||
assert('!is_null($key)');
|
assert('!is_null($key)');
|
||||||
$key = "d-" . $key;
|
|
||||||
|
|
||||||
$val = $this->memcache->get($key);
|
$val = $this->memcache->get($key);
|
||||||
$res = $this->memcache->getResultCode();
|
$res = $this->memcache->getResultCode();
|
||||||
@ -428,7 +427,6 @@ class MemcachedCache implements CacheEngine {
|
|||||||
*/
|
*/
|
||||||
public function set($key, $val, $time=0) {
|
public function set($key, $val, $time=0) {
|
||||||
assert('!is_null($key)');
|
assert('!is_null($key)');
|
||||||
$key = "d-" . $key;
|
|
||||||
|
|
||||||
$this->memcache->set($key, $val, $time);
|
$this->memcache->set($key, $val, $time);
|
||||||
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
||||||
@ -441,7 +439,6 @@ class MemcachedCache implements CacheEngine {
|
|||||||
*/
|
*/
|
||||||
public function delete($key) {
|
public function delete($key) {
|
||||||
assert('!is_null($key)');
|
assert('!is_null($key)');
|
||||||
$key = "d-" . $key;
|
|
||||||
|
|
||||||
$this->memcache->delete($key);
|
$this->memcache->delete($key);
|
||||||
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
|
||||||
@ -549,23 +546,11 @@ class Database {
|
|||||||
$matches = array();
|
$matches = array();
|
||||||
if(defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|memcached|apc)://(.*)#", CACHE_DSN, $matches)) {
|
if(defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|memcached|apc)://(.*)#", CACHE_DSN, $matches)) {
|
||||||
if($matches[1] == "memcache") {
|
if($matches[1] == "memcache") {
|
||||||
if(class_exists("Memcache")) {
|
|
||||||
$this->cache = new MemcacheCache($matches[2]);
|
$this->cache = new MemcacheCache($matches[2]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
#error_log("no memcache module - caching disabled");
|
|
||||||
$this->cache = new NoCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if($matches[1] == "memcached") {
|
else if($matches[1] == "memcached") {
|
||||||
if(class_exists("Memcached")) {
|
|
||||||
$this->cache = new MemcachedCache($matches[2]);
|
$this->cache = new MemcachedCache($matches[2]);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
#error_log("no memcached module - caching disabled");
|
|
||||||
$this->cache = new NoCache();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if($matches[1] == "apc") {
|
else if($matches[1] == "apc") {
|
||||||
$this->cache = new APCCache($matches[2]);
|
$this->cache = new APCCache($matches[2]);
|
||||||
}
|
}
|
||||||
@ -695,17 +680,14 @@ class Database {
|
|||||||
*/
|
*/
|
||||||
private function count_execs($db, $sql, $inputarray) {
|
private function count_execs($db, $sql, $inputarray) {
|
||||||
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
|
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
|
||||||
$fp = @fopen("data/sql.log", "a");
|
|
||||||
if($fp) {
|
|
||||||
$sql = trim(preg_replace('/\s+/msi', ' ', $sql));
|
$sql = trim(preg_replace('/\s+/msi', ' ', $sql));
|
||||||
if(isset($inputarray) && is_array($inputarray) && !empty($inputarray)) {
|
if(isset($inputarray) && is_array($inputarray) && !empty($inputarray)) {
|
||||||
fwrite($fp, $sql." -- ".join(", ", $inputarray)."\n");
|
$text = $sql." -- ".join(", ", $inputarray)."\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fwrite($fp, $sql."\n");
|
$text = $sql."\n";
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
}
|
}
|
||||||
|
file_put_contents("data/sql.log", $text, FILE_APPEND);
|
||||||
}
|
}
|
||||||
if(!is_array($inputarray)) $this->query_count++;
|
if(!is_array($inputarray)) $this->query_count++;
|
||||||
# handle 2-dimensional input arrays
|
# handle 2-dimensional input arrays
|
||||||
@ -715,11 +697,8 @@ class Database {
|
|||||||
|
|
||||||
private function count_time($method, $start) {
|
private function count_time($method, $start) {
|
||||||
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
|
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
|
||||||
$fp = @fopen("data/sql.log", "a");
|
$text = $method.":".(microtime(true) - $start)."\n";
|
||||||
if($fp) {
|
file_put_contents("data/sql.log", $text, FILE_APPEND);
|
||||||
fwrite($fp, $method.":".(microtime(true) - $start)."\n");
|
|
||||||
fclose($fp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->dbtime += microtime(true) - $start;
|
$this->dbtime += microtime(true) - $start;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user