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:
authorMatthieu Napoli <matthieu@mnapoli.fr>2015-02-11 02:48:12 +0300
committerMatthieu Napoli <matthieu@mnapoli.fr>2015-02-11 02:48:12 +0300
commit67698a6b9dd289091dab8f38814255f015f32daf (patch)
tree38ace203864ab2baa846d124c409dab288844290
parente5d2ed3fd1fe7e33c7d2d423825e3bbb605a5e2b (diff)
parentf23c459d86891ad107b1dd494b7479da5cfdd48a (diff)
Merge pull request #7128 from piwik/simpler-cache-config2.11.0-b4
Simplified the cache configuration
-rw-r--r--config/environment/dev.php2
-rw-r--r--config/environment/test.php7
-rw-r--r--config/global.php36
-rw-r--r--core/Translation/Loader/LoaderCache.php5
4 files changed, 15 insertions, 35 deletions
diff --git a/config/environment/dev.php b/config/environment/dev.php
index ab095a7aa5..0a730d708c 100644
--- a/config/environment/dev.php
+++ b/config/environment/dev.php
@@ -2,6 +2,8 @@
return array(
+ 'Piwik\Cache\Backend' => DI\object('Piwik\Cache\Backend\ArrayCache'),
+
'Piwik\Translation\Loader\LoaderInterface' => DI\object('Piwik\Translation\Loader\LoaderCache')
->constructor(DI\link('Piwik\Translation\Loader\DevelopmentLoader')),
'Piwik\Translation\Loader\DevelopmentLoader' => DI\object()
diff --git a/config/environment/test.php b/config/environment/test.php
index 0dfd6d9770..4eac327a6e 100644
--- a/config/environment/test.php
+++ b/config/environment/test.php
@@ -5,8 +5,11 @@ return array(
// Disable logging
'Psr\Log\LoggerInterface' => DI\object('Psr\Log\NullLogger'),
- // Disable translation cache
- 'Piwik\Translation\Loader\LoaderInterface' => DI\object('Piwik\Translation\Loader\JsonFileLoader'),
+ 'Piwik\Cache\Backend' => function () {
+ return \Piwik\Cache::buildBackend('file');
+ },
+ 'cache.eager.cache_id' => 'eagercache-test-',
+
// Disable loading core translations
'Piwik\Translation\Translator' => DI\object()
->constructorParameter('directories', array()),
diff --git a/config/global.php b/config/global.php
index d3d5ac39f6..af8272d3de 100644
--- a/config/global.php
+++ b/config/global.php
@@ -24,34 +24,11 @@ return array(
return $root . '/tmp' . $instanceId;
},
- 'path.cache' => function (ContainerInterface $c) {
- $root = $c->get('path.tmp');
+ 'path.cache' => DI\string('{path.tmp}/cache/tracker/'),
- return $root . '/cache/tracker/';
- },
-
- 'cache.backend' => 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 = 'array';
- } else {
- $backend = $c->get('ini.Cache.backend');
- }
-
- return $backend;
- },
- 'Piwik\Cache\Lazy' => DI\object(),
- 'Piwik\Cache\Transient' => DI\object(),
'Piwik\Cache\Eager' => 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) . '-';
- }
+ $cacheId = $c->get('cache.eager.cache_id');
if (SettingsServer::isTrackerApiRequest()) {
$eventToPersist = 'Tracker.end';
@@ -69,11 +46,10 @@ return array(
return $cache;
},
'Piwik\Cache\Backend' => function (ContainerInterface $c) {
-
- $type = $c->get('cache.backend');
- $backend = \Piwik\Cache::buildBackend($type);
-
- return $backend;
+ return \Piwik\Cache::buildBackend($c->get('ini.Cache.backend'));
+ },
+ 'cache.eager.cache_id' => function () {
+ return 'eagercache-' . str_replace(array('.', '-'), '', \Piwik\Version::VERSION) . '-';
},
// Log
diff --git a/core/Translation/Loader/LoaderCache.php b/core/Translation/Loader/LoaderCache.php
index 8ad7dc1ad9..5448e1aef4 100644
--- a/core/Translation/Loader/LoaderCache.php
+++ b/core/Translation/Loader/LoaderCache.php
@@ -25,11 +25,10 @@ class LoaderCache implements LoaderInterface
*/
private $cache;
- public function __construct(LoaderInterface $loader, Cache\Lazy $cache = null)
+ public function __construct(LoaderInterface $loader, Cache\Lazy $cache)
{
$this->loader = $loader;
- // TODO DI
- $this->cache = $cache ?: Cache::getLazyCache();
+ $this->cache = $cache;
}
/**