caching_BPT/caching_SBPT did NOT really cache a heck, sinche $cache was the local variable!
also, fixed broken pass-by-ref which broke loose search for SBPT
This commit is contained in:
parent
33abf7dcf1
commit
1f7fcf6f38
@ -1759,8 +1759,8 @@ class BPlusTree {
|
|||||||
* @param $key target key
|
* @param $key target key
|
||||||
* @returns bool false if key does not exists, true otherwise
|
* @returns bool false if key does not exists, true otherwise
|
||||||
*/
|
*/
|
||||||
function has_key($key) {
|
function has_key(&$key, $loose=false) {
|
||||||
if (@$this->getitem($key)!==false) {
|
if (@$this->getitem($key, $loose)!==false) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -2510,9 +2510,12 @@ class caching_BPT extends BPlusTree {
|
|||||||
var $cache = array();
|
var $cache = array();
|
||||||
|
|
||||||
function getitem(&$key, $loose=false) {
|
function getitem(&$key, $loose=false) {
|
||||||
if (isset($cache[$key]))
|
if (isset($this->cache[$key]))
|
||||||
return $cache[$key];
|
return $this->cache[$key];
|
||||||
else return ($cache[$key] = parent::getitem($key, $loose));
|
else {
|
||||||
|
$this->cache[$key] = parent::getitem($key, $loose);
|
||||||
|
return $this->cache[$key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetcache() {
|
function resetcache() {
|
||||||
@ -2577,7 +2580,7 @@ class SBPlusTree extends BPlusTree {
|
|||||||
* @param $key target key
|
* @param $key target key
|
||||||
* @returns int seek point if key exists, 0 otherwise
|
* @returns int seek point if key exists, 0 otherwise
|
||||||
*/
|
*/
|
||||||
function has_key($key, $loose=false) {
|
function has_key(&$key, $loose=false) {
|
||||||
return @parent::getitem($key, $loose);
|
return @parent::getitem($key, $loose);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2628,9 +2631,13 @@ class caching_SBPT extends SBPlusTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getitem(&$key, $loose=false) {
|
function getitem(&$key, $loose=false) {
|
||||||
if (isset($cache[$key]))
|
if (isset($this->cache[$key]))
|
||||||
return $cache[$key];
|
return $this->cache[$key];
|
||||||
else return ($cache[$key] = parent::getitem($key, $loose));
|
else {
|
||||||
|
$item = parent::getitem($key, $loose);
|
||||||
|
$this->cache[$key] = $item;
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetcache() {
|
function resetcache() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user