From fe57edd9e87832dbd14ea8ffd2dc2f16ac1ceb6f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 20 Sep 2015 12:38:35 -0400 Subject: Add abstract cache layer --- app/Core/Cache/MemoryCache.php | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 app/Core/Cache/MemoryCache.php (limited to 'app/Core/Cache/MemoryCache.php') diff --git a/app/Core/Cache/MemoryCache.php b/app/Core/Cache/MemoryCache.php new file mode 100644 index 00000000..b1de96bc --- /dev/null +++ b/app/Core/Cache/MemoryCache.php @@ -0,0 +1,65 @@ +storage[$key] = $value; + } + + /** + * Fetch value from cache + * + * @access public + * @param string $key + * @return mixed Null when not found, cached value otherwise + */ + public function get($key) + { + return isset($this->storage[$key]) ? $this->storage[$key] : null; + } + + /** + * Clear all cache + * + * @access public + */ + public function flush() + { + $this->storage = array(); + } + + /** + * Remove cached value + * + * @access public + * @param string $key + */ + public function remove($key) + { + unset($this->storage[$key]); + } +} -- cgit v1.2.3