diff options
author | Demon <chadh@wikimedia.org> | 2012-06-04 20:36:31 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2012-06-04 20:36:31 +0000 |
commit | a2d4193cd9fbea3a789a6bdebca4b12bc88b4370 (patch) | |
tree | 1480fe40462b561f50220aa1200327e562f49dd9 /includes | |
parent | 2737219e97c4fe2a3ea19b8474ce3e5c9e0c7e2f (diff) | |
parent | 3c1495e9686fcb3e1ccdce0f9c3e7efc2ef76420 (diff) | |
download | mediawikicore-a2d4193cd9fbea3a789a6bdebca4b12bc88b4370.tar.gz mediawikicore-a2d4193cd9fbea3a789a6bdebca4b12bc88b4370.zip |
Merge "Made default BagOStuff functions work consistently."
Diffstat (limited to 'includes')
-rw-r--r-- | includes/objectcache/BagOStuff.php | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index 2b266408e426..e6ba04211cb6 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -61,20 +61,6 @@ abstract class BagOStuff { abstract public function get( $key ); /** - * Get an associative array containing the item for each of the given keys. - * Each item will be false if it does not exist. - * @param $keys Array List of strings - * @return Array - */ - public function getMulti( array $keys ) { - $res = array(); - foreach ( $keys as $key ) { - $res[$key] = $this->get( $key ); - } - return $res; - } - - /** * Set an item. * @param $key string * @param $value mixed @@ -136,16 +122,32 @@ abstract class BagOStuff { /* *** Emulated functions *** */ /** + * Get an associative array containing the item for each of the keys that have items. + * @param $keys Array List of strings + * @return Array + */ + public function getMulti( array $keys ) { + $res = array(); + foreach ( $keys as $key ) { + $val = $this->get( $key ); + if ( $val !== false ) { + $res[$key] = $val; + } + } + return $res; + } + + /** * @param $key string * @param $value mixed * @param $exptime integer * @return bool success */ public function add( $key, $value, $exptime = 0 ) { - if ( !$this->get( $key ) ) { + if ( $this->get( $key ) === false ) { return $this->set( $key, $value, $exptime ); } - return true; + return false; // key already set } /** @@ -157,7 +159,7 @@ abstract class BagOStuff { if ( $this->get( $key ) !== false ) { return $this->set( $key, $value, $exptime ); } - return true; + return false; // key not already set } /** |