X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcache%2Fclass_MemoryCache.php;h=dcf378362a6f5ac6ba954f5cba43c914d66bbba3;hp=8dd25379cb01a7b35c1fcf0e209e473451ef7610;hb=4f8c6dfcdc9b0a11ef041d0658f98d10a85e87fa;hpb=b4a01b4e5ea1ce826b6df34f4619f6310c77cd02 diff --git a/inc/classes/main/cache/class_MemoryCache.php b/inc/classes/main/cache/class_MemoryCache.php index 8dd2537..dcf3783 100644 --- a/inc/classes/main/cache/class_MemoryCache.php +++ b/inc/classes/main/cache/class_MemoryCache.php @@ -3,10 +3,10 @@ * A simple memory cache (similar to a registry) * * @author Roland Haeder - * @version 0.3.0 - * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, this is free software * @license GNU GPL 3.0 or any newer version - * @link http://www.mxchange.org + * @link http://www.ship-simu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ class MemoryCache extends BaseFrameworkSystem implements Cacheable { /** @@ -28,7 +28,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { private $dataCache = null; /** - * Private constructor + * Protected constructor * * @return void */ @@ -40,7 +40,7 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { $this->setObjectDescription("Memory cache"); // Create unique ID number - $this->createUniqueID(); + $this->generateUniqueId(); // Clean up a little $this->removeNumberFormaters(); @@ -70,19 +70,50 @@ class MemoryCache extends BaseFrameworkSystem implements Cacheable { */ protected function initCache () { // Now create the "data cache" - $this->dataCache = new FrameworkArrayObject(); + $this->dataCache = new FrameworkArrayObject('FakedDataCache'); } /** * 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]