summaryrefslogtreecommitdiff
path: root/includes/objectcache/HashBagOStuff.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /includes/objectcache/HashBagOStuff.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/objectcache/HashBagOStuff.php')
-rw-r--r--includes/objectcache/HashBagOStuff.php58
1 files changed, 58 insertions, 0 deletions
diff --git a/includes/objectcache/HashBagOStuff.php b/includes/objectcache/HashBagOStuff.php
new file mode 100644
index 00000000..36773306
--- /dev/null
+++ b/includes/objectcache/HashBagOStuff.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * This is a test of the interface, mainly. It stores things in an associative
+ * array, which is not going to persist between program runs.
+ *
+ * @ingroup Cache
+ */
+class HashBagOStuff extends BagOStuff {
+ var $bag;
+
+ function __construct() {
+ $this->bag = array();
+ }
+
+ protected function expire( $key ) {
+ $et = $this->bag[$key][1];
+
+ if ( ( $et == 0 ) || ( $et > time() ) ) {
+ return false;
+ }
+
+ $this->delete( $key );
+
+ return true;
+ }
+
+ function get( $key ) {
+ if ( !isset( $this->bag[$key] ) ) {
+ return false;
+ }
+
+ if ( $this->expire( $key ) ) {
+ return false;
+ }
+
+ return $this->bag[$key][0];
+ }
+
+ function set( $key, $value, $exptime = 0 ) {
+ $this->bag[$key] = array( $value, $this->convertExpiry( $exptime ) );
+ }
+
+ function delete( $key, $time = 0 ) {
+ if ( !isset( $this->bag[$key] ) ) {
+ return false;
+ }
+
+ unset( $this->bag[$key] );
+
+ return true;
+ }
+
+ function keys() {
+ return array_keys( $this->bag );
+ }
+}
+