Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/111362

Change subject: Add method to test if LocalBufferedStorage has data in own 
cache already
......................................................................

Add method to test if LocalBufferedStorage has data in own cache already

Change-Id: Ic35eda44834257a14bfba7619c3f337f2c545dd7
---
M includes/Data/ObjectManager.php
1 file changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/62/111362/1

diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 3943eea..718ecbe 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -1567,8 +1567,19 @@
 class LocalBufferedCache extends BufferedCache {
        protected $internal = array();
 
+       /**
+        * Returns true if the data is in own "storage" already, or false if it 
will
+        * need to be fetched from external cache.
+        *
+        * @param string $key
+        * @return bool
+        */
+       public function has( $key ) {
+               return array_key_exists( $key, $this->internal );
+       }
+
        public function get( $key ) {
-               if ( array_key_exists( $key, $this->internal ) ) {
+               if ( $this->has( $key ) ) {
                        return $this->internal[$key];
                }
                return $this->internal[$key] = parent::get( $key );
@@ -1577,7 +1588,7 @@
        public function getMulti( array $keys ) {
                $found = array();
                foreach ( $keys as $idx => $key ) {
-                       if ( array_key_exists( $key, $this->internal ) ) {
+                       if ( $this->has( $key ) ) {
                                // BagOStuff::multiGet doesn't return the 
unfound keys
                                if ( $this->internal[$key] !== false ) {
                                        $found[$key] = $this->internal[$key];
@@ -1616,7 +1627,7 @@
                        );
                        // speculative ... could cause a ton of bugs due to 
normal assumptions
                        // how to do this reasonably?
-                       if ( !array_key_exists( $key, $this->internal ) || 
$this->internal[$key] === false ) {
+                       if ( !$this->has( $key ) || $this->internal[$key] === 
false ) {
                                $this->internal[$key] = $value;
                        }
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/111362
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic35eda44834257a14bfba7619c3f337f2c545dd7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to