- $this->unlock($key);
- return $m;
- }
-
- function _debug($text) {
- if($this->debugmode)
- wfDebug("BagOStuff debug: $text\n");
- }
-}
-
-
-/**
- * Functional versions!
- * @todo document
- */
-class HashBagOStuff extends BagOStuff {
- /*
- This is a test of the interface, mainly. It stores
- things in an associative array, which is not going to
- persist between program runs.
- */
- var $bag;
-
- function HashBagOStuff() {
- $this->bag = array();
- }
-
- function _expire($key) {
- $et = $this->bag[$key][1];
- if(($et == 0) || ($et > time()))
- return false;
- $this->delete($key);
- return true;
- }
-
- function get($key) {
- if(!$this->bag[$key])
- return false;
- if($this->_expire($key))
- return false;
- return $this->bag[$key][0];
- }
-
- function set($key,$value,$exptime=0) {
- if(($exptime != 0) && ($exptime < 3600*24*30))
- $exptime = time() + $exptime;
- $this->bag[$key] = array( $value, $exptime );
- }
-
- function delete($key,$time=0) {
- if(!$this->bag[$key])
- return false;
- unset($this->bag[$key]);
- return true;
- }
-}
-
-/*
-CREATE TABLE objectcache (
- keyname char(255) binary not null default '',
- value mediumblob,
- exptime datetime,
- unique key (keyname),
- key (exptime)
-);
-*/
-
-/**
- * @todo document
- * @abstract
- */
-class SqlBagOStuff extends BagOStuff {
- var $table;
-
- function SqlBagOStuff($tablename = 'objectcache') {
- $this->table = $tablename;
- }
-
- function get($key) {
- /* expire old entries if any */
- $this->expireall();
-
- $res = $this->_query(
- "SELECT value,exptime FROM $0 WHERE keyname='$1'", $key);
- if(!$res) {
- $this->_debug("get: ** error: " . $this->_dberror($res) . " **");
- return false;