/**
  * Delete cache
  * @param string $id
  * @return boolean
  */
 public function delete($key)
 {
     if (!dba_exists($key, $this->_handler('r'))) {
         return true;
     }
     return dba_delete($key, $this->_handler('w'));
 }
Beispiel #2
0
 public function delete($key)
 {
     $rs = dba_open(DATA_DIR . '/kvstore/dba.db', 'wl', $this->handle);
     $ret = dba_delete($this->create_key($key), $rs);
     dba_close($rs);
     return $ret;
 }
Beispiel #3
0
 function new_access_token($token, $consumer)
 {
     /*{{{*/
     $token = $this->new_token($consumer, 'access');
     dba_delete("request_" . $token->key, $this->dbh);
     return $token;
 }
Beispiel #4
0
function db4_delete($key)
{
    return dba_delete(bin4($key), $GLOBALS['db']);
}
 function add($key, $value, $exptime = 0)
 {
     wfProfileIn(__METHOD__);
     $blob = $this->encode($value, $exptime);
     $handle = $this->getWriter();
     if (!$handle) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $ret = dba_insert($key, $blob, $handle);
     # Insert failed, check to see if it failed due to an expired key
     if (!$ret) {
         list($value, $expiry) = $this->decode(dba_fetch($key, $handle));
         if ($expiry < time()) {
             # Yes expired, delete and try again
             dba_delete($key, $handle);
             $ret = dba_insert($key, $blob, $handle);
             # This time if it failed then it will be handled by the caller like any other race
         }
     }
     dba_close($handle);
     wfProfileOut(__METHOD__);
     return $ret;
 }
Beispiel #6
0
function HyperCacheRetranslation_clean($dbfile)
{
    if (!is_file($dbfile)) {
        return;
    }
    $db_con = dba_open($dbfile, "r", "db4");
    if (!$db_con) {
        events("analyze:: FATAL!!!::{$dbfile}, unable to open");
        return null;
    }
    $mainkey = dba_firstkey($db_con);
    $f = array();
    $c = 0;
    while ($mainkey != false) {
        $fetch_content = @dba_fetch($mainkey, $db_con);
        $array = @unserialize($fetch_content);
        $filepath = $array["TARGET"];
        $FullPath = "{$GLOBALS["HyperCacheStoragePath"]}/{$filepath}";
        if (!is_file($FullPath)) {
            $f[$mainkey] = true;
            $mainkey = dba_nextkey($db_con);
            continue;
        }
        $mainkey = dba_nextkey($db_con);
    }
    @dba_close($db_con);
    if (count($f) == 0) {
        return;
    }
    $db_con = dba_open($dbfile, "c", "db4");
    if (!$db_con) {
        events("analyze:: FATAL!!!::{$dbfile}, unable to open");
        return null;
    }
    while (list($mainkey, $filetype) = each($f)) {
        dba_delete($mainkey, $db_con);
    }
    @dba_close($db_con);
}
Beispiel #7
0
 public function delete($key)
 {
     unset($this->cache[$key]);
     return dba_delete($key, $this->dbHandler);
 }
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This library is distributed in the hope that it will be useful,      |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// |                                                                      |
// | You should have received a copy of the GNU Lesser General Public     |
// | License along with this library; if not, write to the Free Software  |
// | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA|
// +----------------------------------------------------------------------+
// | Author: Brent Cook <*****@*****.**>                         |
// +----------------------------------------------------------------------+
//
// $Id: test_compatibility.php,v 1.2 2003/01/04 11:54:51 mj Exp $
//
// test functionality of the dba compatibility layer
require_once 'DBA/Compatibility.php';
$id = dba_open("file_test", "n", "db3");
if (!$id) {
    echo "dba_open failed\n";
    exit;
}
dba_insert("key", "This is an example!", $id);
dba_replace("key", "This is another example!", $id);
if (dba_exists("key", $id)) {
    echo dba_fetch("key", $id);
    dba_delete("key", $id);
}
dba_close($id);
Beispiel #9
0
 function new_access_token($token, $consumer)
 {
     // TODO: check if request token is authorized first
     $token = $this->new_token($consumer, 'access');
     dba_delete("request_" . $token->key, $this->dbh);
     return $token;
 }
Beispiel #10
0
Datei: Dba.php Projekt: blar/dba
 /**
  * Remove values from the database.
  *
  * @param string $key
  */
 public function removeValues(string $key)
 {
     $key = $this->addNamespaceToKey($key);
     $result = dba_delete($key, $this->getHandle());
     if (!$result) {
         throw new RuntimeException('Remove failed');
     }
 }
Beispiel #11
0
 function set($key, $val)
 {
     $dbh =& $this->_dbh;
     if ($this->readonly) {
         return;
     }
     if (dba_exists($key, $dbh)) {
         if ($val !== false) {
             if (!dba_replace($key, $val, $dbh)) {
                 return $this->_error("store[replace]({$key})");
             }
         } else {
             if (!dba_delete($key, $dbh)) {
                 return $this->_error("store[delete]({$key})");
             }
         }
     } else {
         if (!dba_insert($key, $val, $dbh)) {
             return $this->_error("store[insert]({$key})");
         }
     }
 }
 /**
  * Inserts a new value at key. If the key/value pair
  * already exist, overwrites the value
  *
  * @access public
  * @param   $key    string the key to insert
  * @param   $value  string the value to store
  * @return  object  PEAR_Error on failure
  */
 function replace($key, $value)
 {
     if ($this->isWritable()) {
         if ($this->_hasReplace) {
             return dba_replace($key, $value, $this->_dba);
         } else {
             $r = true;
             if (dba_exists($key, $this->_dba)) {
                 $r = dba_delete($key, $this->_dba);
             }
             return $r && dba_insert($key, $value, $this->_dba);
         }
     } else {
         return $this->raiseError(DBA_ERROR_NOT_WRITEABLE);
     }
 }
Beispiel #13
0
 function deletePage($pagename)
 {
     if (dba_exists("" . $pagename, $this->db)) {
         $key = dba_fetch("" . $pagename, $this->db);
         $keyval = unpack($this->type . '1' . $this->type, $key);
         dba_delete("" . $key, $this->db);
         dba_delete("" . $pagename, $this->db);
         return true;
     }
     return false;
 }
 public function remove($key)
 {
     $db = dba_open($this->filePath, 'wl', 'db4');
     $response = dba_delete($key, $db);
     return $response;
 }
function STATS_BuildCurrentWeek_move($key, $newkey)
{
    $path = "/home/artica/postfix/WEEK";
    $dbpath = "{$path}/" . date("YW") . ".db";
    $db_con = dba_open($dbpath, "c", "db4");
    if (!$db_con) {
        echo "DB open {$path} failed\n";
        return false;
    }
    echo "{$key} -> {$newkey}\n";
    $data = dba_fetch($key, $db_con);
    dba_delete($key, $db_con);
    dba_replace($newkey, $data, $db_con);
    @dba_close($db_con);
}
Beispiel #16
0
 public function delete($key)
 {
     return dba_delete($this->create_key($key), $this->rs);
 }
<?php

$handler = 'cdb';
require_once dirname(__FILE__) . '/test.inc';
echo "Test 0\n";
if (($db_file = dba_open($db_filename, 'n', $handler)) !== FALSE) {
    var_dump(dba_insert("key1", "Content String 1", $db_file));
    var_dump(dba_replace("key1", "New Content String", $db_file));
    var_dump(dba_fetch("key1", $db_file));
    var_dump(dba_firstkey($db_file));
    var_dump(dba_delete("key1", $db_file));
    var_dump(dba_optimize($db_file));
    var_dump(dba_sync($db_file));
    dba_close($db_file);
} else {
    echo "Failed to open DB\n";
}
unlink($db_filename);
echo "Test 1\n";
if (($db_file = dba_open($db_filename, 'c', $handler)) !== FALSE) {
    dba_insert("key1", "Content String 1", $db_file);
    dba_close($db_file);
} else {
    echo "Failed to open DB\n";
}
echo "Test 2\n";
if (($db_file = dba_open($db_filename, 'r', $handler)) !== FALSE) {
    dba_insert("key1", "Content String 1", $db_file);
    dba_close($db_file);
} else {
    echo "Failed to open DB\n";
Beispiel #18
0
function del_entry($key)
{
    $error = NOERR;
    if (!($id = dba_open(FILEDB_PATH, "wd", FILEDB_HANDLER))) {
        return ERROR;
    }
    if (dba_delete($key, $id)) {
        $error = ERROR;
    }
    dba_close($id);
    return $error;
}
<?php

$handler = "inifile";
include "test.inc";
$dba = dba_open($db_filename, "n", $handler) or die;
for ($i = 0; $i < 3; ++$i) {
    echo "insert {$i}:";
    var_dump(dba_insert("a", $i, $dba));
}
echo "exists:";
var_dump(dba_exists("a", $dba));
echo "delete:";
var_dump(dba_delete("a", $dba));
echo "exists:";
var_dump(dba_exists("a", $dba));
echo "delete:";
var_dump(dba_delete("a", $dba));
?>
===DONE===
Beispiel #20
0
 /**
  * Deletes a record from the database.
  * 
  * @access	public
  * @param	string	$key
  * @return	boolean
  * 
  */
 function delete($key)
 {
     return @dba_delete($key, $this->connection);
 }
Beispiel #21
0
 public function delete($key)
 {
     //if (array_key_exists($key,$this->cache)) {
     unset($this->cache[$key]);
     return dba_delete($key, $this->db_handler);
 }
Beispiel #22
0
 /**
  * Remove a token from the database.
  *
  * @access protected
  * @param string $token
  * @return bool TRUE on success or FALSE on failure
  */
 protected function _del($token)
 {
     return dba_delete($token, $this->_db);
 }
 public function newAccessToken($token, $consumer)
 {
     $token = $this->newToken($consumer, 'access');
     dba_delete("request_" . $token->getKey(), $this->dbh);
     return $token;
 }
Beispiel #24
0
 function delete($key)
 {
     if (dba_exists($key, $this->_id)) {
         return dba_delete($key, $this->_id);
     }
     return 1;
 }
Beispiel #25
0
 /**
  * Internal method to remove an item.
  *
  * @param  string $normalizedKey
  * @return bool
  * @throws Exception\ExceptionInterface
  */
 protected function internalRemoveItem(&$normalizedKey)
 {
     $options = $this->getOptions();
     $namespace = $options->getNamespace();
     $prefix = $namespace === '' ? '' : $namespace . $options->getNamespaceSeparator();
     $internalKey = $prefix . $normalizedKey;
     $this->_open();
     // Workaround for PHP-Bug #62490
     if (!dba_exists($internalKey, $this->handle)) {
         return false;
     }
     return dba_delete($internalKey, $this->handle);
 }
Beispiel #26
0
 /**
  * @return bool
  */
 public function bDelete($sKey)
 {
     return dba_delete($sKey, $this->_hFile);
 }
Beispiel #27
0
 function new_access_token($token, $consumer)
 {
     /*{{{*/
     $user = $this->lookup_user($consumer->key, $token->key);
     if (empty($user) || is_array($user)) {
         return FALSE;
     }
     $actok = $this->new_token($consumer, 'access');
     dba_delete("request_" . $token->key, $this->dbh);
     $this->del_usermap('userX', $token->key);
     // delete request-token/consumer link
     $this->del_usermap('userT', $token->key);
     $this->new_usermap($user, 'userT', $consumer->key, $actok->key);
     return $actok;
 }
Beispiel #28
0
 /**
  * Removes a specified key from this database
  *
  * @param   string key
  * @return  bool success
  * @throws  io.IOException in case writing failed
  */
 public function delete($key)
 {
     if (!dba_delete($key, $this->_fd)) {
         throw new IOException('Could not delete key "' . $key . '"');
     }
     return TRUE;
 }
Beispiel #29
0
 /**
  * @param $key string
  * @param $step integer
  * @return integer|bool
  */
 public function incr($key, $step = 1)
 {
     wfProfileIn(__METHOD__);
     $handle = $this->getWriter();
     if (!$handle) {
         wfProfileOut(__METHOD__);
         return false;
     }
     list($value, $expiry) = $this->decode(dba_fetch($key, $handle));
     if ($value !== false) {
         if ($expiry && $expiry < time()) {
             # Key is expired, delete it
             dba_delete($key, $handle);
             wfDebug(__METHOD__ . ": {$key} expired\n");
             $value = false;
         } else {
             $value += $step;
             $blob = $this->encode($value, $expiry);
             $ret = dba_replace($key, $blob, $handle);
             $value = $ret ? $value : false;
         }
     }
     dba_close($handle);
     wfProfileOut(__METHOD__);
     return $value === false ? false : (int) $value;
 }
Beispiel #30
0
 function DELETE($id, $version)
 {
     dba_delete("{$id}.{$version}", $this->handle);
 }