當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Cache::buildBackend方法代碼示例

本文整理匯總了PHP中Piwik\Cache::buildBackend方法的典型用法代碼示例。如果您正苦於以下問題:PHP Cache::buildBackend方法的具體用法?PHP Cache::buildBackend怎麽用?PHP Cache::buildBackend使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\Cache的用法示例。


在下文中一共展示了Cache::buildBackend方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

<?php

use Interop\Container\ContainerInterface;
use Piwik\Common;
use Piwik\Tests\Framework\Mock\FakeAccess;
use Piwik\Tests\Framework\Mock\TestConfig;
return array('Psr\\Log\\LoggerInterface' => DI\object('Psr\\Log\\NullLogger'), 'Piwik\\Cache\\Backend' => function () {
    return \Piwik\Cache::buildBackend('file');
}, 'cache.eager.cache_id' => 'eagercache-test-', 'Piwik\\Translation\\Translator' => DI\decorate(function ($previous, ContainerInterface $c) {
    $loadRealTranslations = $c->get('test.vars.loadRealTranslations');
    if (!$loadRealTranslations) {
        return new \Piwik\Translation\Translator($c->get('Piwik\\Translation\\Loader\\LoaderInterface'), $directories = array());
    } else {
        return $previous;
    }
}), 'Piwik\\Config' => DI\decorate(function ($previous, ContainerInterface $c) {
    $testingEnvironment = $c->get('Piwik\\Tests\\Framework\\TestingEnvironmentVariables');
    $dontUseTestConfig = $c->get('test.vars.dontUseTestConfig');
    if (!$dontUseTestConfig) {
        $settingsProvider = $c->get('Piwik\\Application\\Kernel\\GlobalSettingsProvider');
        return new TestConfig($settingsProvider, $testingEnvironment, $allowSave = false, $doSetTestEnvironment = true);
    } else {
        return $previous;
    }
}), 'Piwik\\Access' => DI\decorate(function ($previous, ContainerInterface $c) {
    $testUseMockAuth = $c->get('test.vars.testUseMockAuth');
    if ($testUseMockAuth) {
        $access = new FakeAccess();
        FakeAccess::$superUser = true;
        FakeAccess::$superUserLogin = 'superUserLogin';
        return $access;
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:31,代碼來源:test.php

示例2: function

        $instanceId = $instanceId ? '/' . $instanceId : '';
    } else {
        $instanceId = '';
    }
    return $root . '/tmp' . $instanceId;
}, 'path.cache' => DI\string('{path.tmp}/cache/tracker/'), 'Piwik\\Cache\\Eager' => function (ContainerInterface $c) {
    $backend = $c->get('Piwik\\Cache\\Backend');
    $cacheId = $c->get('cache.eager.cache_id');
    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' => function (ContainerInterface $c) {
    try {
        $backend = $c->get('ini.Cache.backend');
    } catch (NotFoundException $ex) {
        $backend = 'chained';
        // happens if global.ini.php is not available
    }
    return \Piwik\Cache::buildBackend($backend);
}, 'cache.eager.cache_id' => function () {
    return 'eagercache-' . str_replace(array('.', '-'), '', \Piwik\Version::VERSION) . '-';
}, 'Psr\\Log\\LoggerInterface' => DI\object('Psr\\Log\\NullLogger'), 'Piwik\\Translation\\Loader\\LoaderInterface' => DI\object('Piwik\\Translation\\Loader\\LoaderCache')->constructor(DI\get('Piwik\\Translation\\Loader\\JsonFileLoader')), 'observers.global' => array(), 'Piwik\\EventDispatcher' => DI\object()->constructorParameter('observers', DI\get('observers.global')));
開發者ID:nagyistoce,項目名稱:piwik,代碼行數:31,代碼來源:global.php

示例3: array

use Piwik\SettingsServer;
return array('path.root' => PIWIK_USER_PATH, 'path.tmp' => function (ContainerInterface $c) {
    $root = $c->get('path.root');
    // TODO remove that special case and instead have plugins override 'path.tmp' to add the instance id
    if ($c->has('ini.General.instance_id')) {
        $instanceId = $c->get('ini.General.instance_id');
        $instanceId = $instanceId ? '/' . $instanceId : '';
    } else {
        $instanceId = '';
    }
    return $root . '/tmp' . $instanceId;
}, 'path.cache' => DI\string('{path.tmp}/cache/tracker/'), 'Piwik\\Cache\\Eager' => function (ContainerInterface $c) {
    $backend = $c->get('Piwik\\Cache\\Backend');
    $cacheId = $c->get('cache.eager.cache_id');
    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' => function (ContainerInterface $c) {
    return \Piwik\Cache::buildBackend($c->get('ini.Cache.backend'));
}, 'cache.eager.cache_id' => function () {
    return 'eagercache-' . str_replace(array('.', '-'), '', \Piwik\Version::VERSION) . '-';
}, 'Psr\\Log\\LoggerInterface' => DI\object('Psr\\Log\\NullLogger'), 'Piwik\\Translation\\Loader\\LoaderInterface' => DI\object('Piwik\\Translation\\Loader\\LoaderCache')->constructor(DI\get('Piwik\\Translation\\Loader\\JsonFileLoader')));
開發者ID:bossrabbit,項目名稱:piwik,代碼行數:31,代碼來源:global.php


注:本文中的Piwik\Cache::buildBackend方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。