]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/cache/class_MemoryCache.php
UserDatabaseWrapper is now changeable by config
[shipsimu.git] / inc / classes / main / cache / class_MemoryCache.php
index 8dd25379cb01a7b35c1fcf0e209e473451ef7610..68a4122decd67a39273bca78cffa7b7958457a9c 100644 (file)
@@ -28,7 +28,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
        private $dataCache = null;
 
        /**
-        * Private constructor
+        * Protected constructor
         *
         * @return      void
         */
@@ -76,13 +76,44 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable {
        /**
         * Does the specified offset exist in cache?
         *
-        * @param       $offset         The offsrt we are looking for
+        * @param       $offset         The offset we are looking for
         * @return      $exists         Wether the offset exists
         */
        public final function offsetExists ($offset) {
                $exists = $this->dataCache->offsetExists($offset);
                return $exists;
        }
+
+       /**
+        * Setter for cache offset
+        *
+        * @param       $offset         The offset we shall set
+        * @param       $data           Data to store in the cache
+        * @return      void
+        */
+       public final function offsetSet ($offset, $data) {
+               $this->dataCache->offsetSet($offset, $data);
+       }
+
+       /**
+        * Getter for cache offset or "null" if not found
+        *
+        * @param       $offset         The offset we shall set
+        * @return      $data           Data to store in the cache
+        */
+       public final function offsetget ($offset) {
+               // Default is offset not found
+               $data = null;
+
+               // Is the offset there?
+               if ($this->offsetExists($offset)) {
+                       // Then get the data from it
+                       $data = $this->dataCache->offsetGet($offset);
+               }
+
+               // Return data
+               return $data;
+       }
 }
 
 // [EOF]