1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?php rcs_id('$Id: DbaPartition.php,v 1.2 2004/11/21 11:59:14 rurban Exp $');
class DbaPartition
{
function DbaPartition(&$dbm, $prefix) {
$this->_h = &$dbm;
$this->_p = $prefix;
}
function open($mode = 'w') {
$this->_h->open();
}
function close() {
$this->_h->close();
}
function firstkey() {
$dbh = &$this->_h;
$prefix = &$this->_p;
$n = strlen($prefix);
for ($key = $dbh->firstkey(); $key !== false; $key = $dbh->nextkey()) {
if (substr($key, 0, $n) == $prefix)
return (string) substr($key, $n);
}
return false;
}
function nextkey() {
$dbh = &$this->_h;
$prefix = &$this->_p;
$n = strlen($prefix);
for ($key = $dbh->nextkey(); $key !== false; $key = $dbh->nextkey()) {
if (substr($key, 0, $n) == $prefix)
return (string) substr($key, $n);
}
return false;
}
function exists($key) {
return $this->_h->exists($this->_p . $key);
}
function fetch($key) {
return $this->_h->fetch($this->_p . $key);
}
function insert($key, $val) {
return $this->_h->insert($this->_p . $key, $val);
}
function replace($key, $val) {
return $this->_h->replace($this->_p . $key, $val);
}
function delete($key) {
return $this->_h->delete($this->_p . $key);
}
function get($key) {
return $this->_h->get($this->_p . $key);
}
function set($key, $val) {
return $this->_h->set($this->_p . $key, $val);
}
function sync() {
return $this->_h->sync();
}
function optimize() {
return $this->_h->optimize();
}
}
// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>
|