diff --git a/cache.class.php b/cache.class.php index 9969671..c684671 100644 --- a/cache.class.php +++ b/cache.class.php @@ -85,7 +85,7 @@ public function store($key, $data, $expiration = 0) { } else { $dataArray = array($key => $storeData); } - $cacheData = json_encode($dataArray); + $cacheData = serialize($dataArray); file_put_contents($this->getCacheDir(), $cacheData); return $this; } @@ -135,7 +135,7 @@ public function erase($key) { if (true === is_array($cacheData)) { if (true === isset($cacheData[$key])) { unset($cacheData[$key]); - $cacheData = json_encode($cacheData); + $cacheData = serialize($cacheData); file_put_contents($this->getCacheDir(), $cacheData); } else { throw new Exception("Error: erase() - Key '{$key}' not found."); @@ -160,7 +160,7 @@ public function eraseExpired() { } } if ($counter > 0) { - $cacheData = json_encode($cacheData); + $cacheData = serialize($cacheData); file_put_contents($this->getCacheDir(), $cacheData); } return $counter; @@ -189,7 +189,7 @@ public function eraseAll() { private function _loadCache() { if (true === file_exists($this->getCacheDir())) { $file = file_get_contents($this->getCacheDir()); - return json_decode($file, true); + return unserialize($file, true); } else { return false; } @@ -309,4 +309,4 @@ public function getExtension() { return $this->_extension; } -} \ No newline at end of file +}