diff options
Diffstat (limited to 'core/DeviceDetectorCache.php')
-rw-r--r-- | core/DeviceDetectorCache.php | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/core/DeviceDetectorCache.php b/core/DeviceDetectorCache.php index c337b1b0a4..bd66523519 100644 --- a/core/DeviceDetectorCache.php +++ b/core/DeviceDetectorCache.php @@ -18,7 +18,7 @@ use Exception; * * Static caching speeds up multiple detections in one request, which is the case when sending bulk requests */ -class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface +class DeviceDetectorCache implements \DeviceDetector\Cache\Cache { protected static $staticCache = array(); @@ -37,7 +37,7 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface * @param string $id The cache entry ID * @return array|bool False on error, or array the cache content */ - public function get($id) + public function fetch($id) { if (empty($id)) { return false; @@ -58,7 +58,7 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface * @throws \Exception * @return bool True if the entry was succesfully stored */ - public function set($id, $content) + public function save($id, $content, $ttl=0) { if (empty($id)) { return false; @@ -69,4 +69,25 @@ class DeviceDetectorCache implements \DeviceDetector\Cache\CacheInterface return $this->cache->save($id, $content, $this->ttl); } + public function contains($id) + { + return !empty(self::$staticCache[$id]) && $this->cache->contains($id); + } + + public function delete($id) + { + if (empty($id)) { + return false; + } + + unset(self::$staticCache[$id]); + + return $this->cache->delete($id); + } + + public function flushAll() + { + return $this->cache->flushAll(); + } + } |