Fixed handling of cache keys as empty results caused cache keys to exist. :(
[core.git] / inc / classes / main / cache / class_MemoryCache.php
index 55bf24db2e2ee14d1ff67a76ec5dba9847c6b061..7f254d3367f2abd2d722be7a4c8f1ea819f82972 100644 (file)
@@ -66,11 +66,31 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
        /**
         * Does the specified offset exist in cache?
         *
-        * @param       $offset         The offset we are looking for
-        * @return      $exists         Whether the offset exists
+        * @param       $offset                 The offset we are looking for
+        * @param       $arrayElement   If type is array, then this element must be found
+        * @param       $minimumCount   If array element is found then this count must at least match
+        * @return      $exists                 Whether the offset exists
         */
-       public function offsetExists ($offset) {
+       public function offsetExists ($offset, $arrayElement = NULL, $minimumCount = 0) {
+               // Is it there?
                $exists = $this->dataCache->offsetExists($offset);
+
+               // So look for array element?
+               if (($exists === TRUE) && (!is_null($arrayElement))) {
+                       // Get it
+                       $array = $this->offetget($offset);
+
+                       // Is it an array and element is found?
+                       if ((is_array($array)) && (isset($array[$arrayElement]))) {
+                               // Is an array and element is found, so check count
+                               $exists = (count($array[$arrayElement]) >= $minimumCount);
+                       } else {
+                               // Not found
+                               $exists = FALSE;
+                       }
+               } // END - if
+
+               // Return status
                return $exists;
        }