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
path: root/config
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-12-17 00:25:51 +0300
committerThomas Steur <thomas.steur@googlemail.com>2014-12-17 00:25:51 +0300
commit1634607051341f6d348404cd4bc478cf2474a259 (patch)
tree8893897d8cdb2b5313a3a2f3f6fac39ce1b56755 /config
parentc0f24c160ab2f573a06146c66fa7fc7bab97a3a7 (diff)
added support for different caching backends such as redis
Diffstat (limited to 'config')
-rw-r--r--config/global.ini.php25
-rw-r--r--config/global.php54
2 files changed, 79 insertions, 0 deletions
diff --git a/config/global.ini.php b/config/global.ini.php
index 559ba5987e..0692f8b9b8 100644
--- a/config/global.ini.php
+++ b/config/global.ini.php
@@ -78,6 +78,31 @@ log_only_when_debug_parameter = 0
; if configured to log in a file, log entries will be made to this file
logger_file_path = tmp/logs/piwik.log
+[Cache]
+; available backends are 'file', 'array', 'null', 'redis', 'chained'
+; 'array' will cache data only during one request
+; 'null' will not cache anything at all
+; 'file' will cache on the filesystem
+; 'redis' will cache on a Redis server, use this if you are running Piwik with multiple servers. Further configuration in [RedisCache] is needed
+; 'chained' will chain multiple cache backends. Further configuration in [ChainedCache] is needed
+backend = chained
+
+[ChainedCache]
+; The chained cache will always try to read from the fastest backend first (the first listed one) to avoid requesting
+; the same cache entry from the slowest backend multiple times in one request.
+backends[] = array
+backends[] = file
+
+[RedisCache]
+; Redis server configuration.
+host = "127.0.0.1"
+port = 6379
+timeout = 0.0
+password = ""
+database = 14
+; In case you are using queued tracking: Make sure to configure a different database! Otherwise queued requests might
+; be flushed
+
[Debug]
; if set to 1, the archiving process will always be triggered, even if the archive has already been computed
; this is useful when making changes to the archiving code so we can force the archiving process
diff --git a/config/global.php b/config/global.php
index 7dc6daa18f..29559349b7 100644
--- a/config/global.php
+++ b/config/global.php
@@ -1,6 +1,8 @@
<?php
use Interop\Container\ContainerInterface;
+use Piwik\Cache\Eager;
+use Piwik\SettingsServer;
return array(
@@ -20,4 +22,56 @@ return array(
return $root . '/tmp' . $instanceId;
}),
+ 'path.cache' => DI\factory(function (ContainerInterface $c) {
+ $root = $c->get('path.tmp');
+
+ return $root . '/cache/tracker/';
+ }),
+
+ 'cache.backend' => DI\factory(function (ContainerInterface $c) {
+ if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE) { // todo replace this with isTest() instead of isCli()
+ $backend = 'file';
+ } elseif (\Piwik\Development::isEnabled()) {
+ $backend = 'null';
+ } else {
+ $backend = $c->get('old_config.Cache.backend');
+ }
+
+ return $backend;
+ }),
+ 'Piwik\Cache\Lazy' => DI\object(),
+ 'Piwik\Cache\Transient' => DI\object(),
+ 'Piwik\Cache\Eager' => DI\factory(function (ContainerInterface $c) {
+
+ $backend = $c->get('Piwik\Cache\Backend');
+
+ if (defined('PIWIK_TEST_MODE') && PIWIK_TEST_MODE) {
+ $cacheId = 'eagercache-test-';
+ } else {
+ $cacheId = 'eagercache-' . str_replace(array('.', '-'), '', \Piwik\Version::VERSION) . '-';
+ }
+
+ if (SettingsServer::isTrackerApiRequest()) {
+ $eventToPersist = 'Tracker.end';
+ $cacheId .= 'tracker';
+ } else {
+ $eventToPersist = 'Request.dispatch.end';
+ $cacheId .= 'ui';
+ }
+
+ $cache = new Eager($backend, $cacheId);
+ \Piwik\Piwik::addAction($eventToPersist, function () use ($cache) {
+ $cache->persistCacheIfNeeded(43200);
+ });
+
+ return $cache;
+ }),
+ 'Piwik\Cache\Backend' => DI\factory(function (ContainerInterface $c) {
+
+ $type = $c->get('cache.backend');
+ $backend = \Piwik\Cache::buildBackend($type);
+
+ return $backend;
+ }),
+
);