Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Tracker/Cache.php')
-rw-r--r--core/Tracker/Cache.php52
1 files changed, 29 insertions, 23 deletions
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index b8f0413c63..a29427fd8b 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -10,7 +10,7 @@ namespace Piwik\Tracker;
use Piwik\Access;
use Piwik\ArchiveProcessor\Rules;
-use Piwik\CacheFile;
+use Piwik\Cache as PiwikCache;
use Piwik\Common;
use Piwik\Config;
use Piwik\Option;
@@ -23,19 +23,29 @@ use Piwik\Tracker;
*/
class Cache
{
+ private static $cacheIdGeneral = 'general';
+
/**
* Public for tests only
- * @var CacheFile
+ * @var \Piwik\Cache\Lazy
*/
- public static $trackerCache = null;
+ public static $cache;
- protected static function getInstance()
+ /**
+ * @return \Piwik\Cache\Lazy
+ */
+ private static function getCache()
{
- if (is_null(self::$trackerCache)) {
- $ttl = Config::getInstance()->Tracker['tracker_cache_file_ttl'];
- self::$trackerCache = new CacheFile('tracker', $ttl);
+ if (is_null(self::$cache)) {
+ self::$cache = PiwikCache::getLazyCache();
}
- return self::$trackerCache;
+
+ return self::$cache;
+ }
+
+ private static function getTtl()
+ {
+ return Config::getInstance()->Tracker['tracker_cache_file_ttl'];
}
/**
@@ -55,8 +65,9 @@ class Cache
return array();
}
- $cache = self::getInstance();
- $cacheContent = $cache->get($idSite);
+ $cache = self::getCache();
+ $cacheId = (int) $idSite;
+ $cacheContent = $cache->fetch($cacheId);
if (false !== $cacheContent) {
return $cacheContent;
@@ -91,7 +102,7 @@ class Cache
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
- $cache->set($idSite, $content);
+ $cache->save($cacheId, $content, self::getTtl());
}
return $content;
@@ -102,7 +113,7 @@ class Cache
*/
public static function clearCacheGeneral()
{
- self::getInstance()->delete('general');
+ self::getCache()->delete(self::$cacheIdGeneral);
}
/**
@@ -113,10 +124,8 @@ class Cache
*/
public static function getCacheGeneral()
{
- $cache = self::getInstance();
- $cacheId = 'general';
-
- $cacheContent = $cache->get($cacheId);
+ $cache = self::getCache();
+ $cacheContent = $cache->fetch(self::$cacheIdGeneral);
if (false !== $cacheContent) {
return $cacheContent;
@@ -162,11 +171,9 @@ class Cache
*/
public static function setCacheGeneral($value)
{
- $cache = self::getInstance();
- $cacheId = 'general';
- $cache->set($cacheId, $value);
+ $cache = self::getCache();
- return true;
+ return $cache->save(self::$cacheIdGeneral, $value, self::getTtl());
}
/**
@@ -193,8 +200,7 @@ class Cache
*/
public static function deleteCacheWebsiteAttributes($idSite)
{
- $idSite = (int)$idSite;
- self::getInstance()->delete($idSite);
+ self::getCache()->delete((int) $idSite);
}
/**
@@ -202,6 +208,6 @@ class Cache
*/
public static function deleteTrackerCache()
{
- self::getInstance()->deleteAll();
+ self::getCache()->flushAll();
}
}