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


PHP Libraries::cache方法代碼示例

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


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

示例1: setUp

 public function setUp()
 {
     Libraries::cache(false);
     $this->classes = array('response' => 'lithium\\tests\\mocks\\console\\MockResponse');
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     chdir(LITHIUM_LIBRARY_PATH . '/lithium');
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->request->params = array('library' => 'build_test');
 }
開發者ID:WarToaster,項目名稱:HangOn,代碼行數:11,代碼來源:TestTest.php

示例2: setUp

 public function setUp()
 {
     Libraries::cache(false);
     $this->classes = array('response' => 'lithium\\tests\\mocks\\console\\MockResponse');
     $this->_backup['cwd'] = getcwd();
     $this->_backup['_SERVER'] = $_SERVER;
     $_SERVER['argv'] = array();
     Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
     $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
     $this->request->params = array('library' => 'create_test');
 }
開發者ID:EHER,項目名稱:monopolis,代碼行數:11,代碼來源:TestTest.php

示例3: array

 * Lithium: the most rad php framework
 *
 * @copyright     Copyright 2010, Union of RAD (http://union-of-rad.org)
 * @license       http://opensource.org/licenses/bsd-license.php The BSD License
 */
/**
 * This file creates a default cache configuration using the most optimized adapter available, and
 * uses it to provide default caching for high-overhead operations.
 */
use lithium\storage\Cache;
use lithium\core\Libraries;
use lithium\action\Dispatcher;
use lithium\storage\cache\adapter\Apc;
/**
 * If APC is not available and the cache directory is not writeable, bail out.
 */
if (!($apcEnabled = Apc::enabled() && !is_writable(LITHIUM_APP_PATH . '/resources/tmp/cache'))) {
    return;
}
Cache::config(array('default' => array('adapter' => '\\lithium\\storage\\cache\\adapter\\' . ($apcEnabled ? 'Apc' : 'File'))));
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    if ($cache = Cache::read('default', 'core.libraries')) {
        $cache = (array) unserialize($cache) + Libraries::cache();
        Libraries::cache($cache);
    }
    $result = $chain->next($self, $params, $chain);
    if ($cache != Libraries::cache()) {
        Cache::write('default', 'core.libraries', serialize(Libraries::cache()), '+1 day');
    }
    return $result;
});
開發者ID:adityamooley,項目名稱:Lithium-Blog-Tutorial,代碼行數:31,代碼來源:cache.php

示例4: array

 * removed post-install, and the cache should be configured with the adapter you plan to use.
 */
$cachePath = Libraries::get(true, 'resources') . '/tmp/cache';
if (!($apcEnabled = Apc::enabled()) && !is_writable($cachePath)) {
    return;
}
/**
 * This configures the default cache, based on whether ot not APC user caching is enabled. If it is
 * not, file caching will be used. Most of this code is for getting you up and running only, and
 * should be replaced with a hard-coded configuration, based on the cache(s) you plan to use.
 */
$default = array('adapter' => 'File', 'strategies' => array('Serializer'));
if ($apcEnabled) {
    $default = array('adapter' => 'Apc');
}
Cache::config(compact('default'));
/**
 * Caches paths for auto-loaded and service-located classes.
 */
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    $key = md5(LITHIUM_APP_PATH) . '.core.libraries';
    if ($cache = Cache::read('default', $key)) {
        $cache = (array) $cache + Libraries::cache();
        Libraries::cache($cache);
    }
    $result = $chain->next($self, $params, $chain);
    if ($cache != Libraries::cache()) {
        Cache::write('default', $key, Libraries::cache(), '+1 day');
    }
    return $result;
});
開發者ID:tmaiaroto,項目名稱:li3b_core,代碼行數:31,代碼來源:cache.php

示例5: function

 *  2. Cache describe calls on all connections that use a `Database` based adapter.
 *
 * @see lithium\core\Environment
 * @see lithium\core\Libraries
 */
if (!Environment::is('production')) {
    return;
}
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    $cacheKey = 'core.libraries';
    if ($cached = Cache::read('default', $cacheKey)) {
        $cached = (array) $cached + Libraries::cache();
        Libraries::cache($cached);
    }
    $result = $chain->next($self, $params, $chain);
    if ($cached != ($data = Libraries::cache())) {
        Cache::write('default', $cacheKey, $data, '+1 day');
    }
    return $result;
});
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    foreach (Connections::get() as $name) {
        if (!($connection = Connections::get($name)) instanceof Database) {
            continue;
        }
        $connection->applyFilter('describe', function ($self, $params, $chain) use($name) {
            if ($params['fields']) {
                return $chain->next($self, $params, $chain);
            }
            $cacheKey = "data.connections.{$name}.sources.{$params['entity']}.schema";
            return Cache::read('default', $cacheKey, array('write' => function () use($self, $params, $chain) {
開發者ID:nilamdoc,項目名稱:OxOPDF,代碼行數:31,代碼來源:cache.php

示例6: testClassInstanceWithSubnamespace

 public function testClassInstanceWithSubnamespace()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/test_app';
     mkdir($testApp);
     $paths = array("/controllers", "/controllers/admin");
     foreach ($paths as $path) {
         $namespace = str_replace('/', '\\', $path);
         $dotsyntax = str_replace('/', '.', trim($path, '/'));
         $class = 'Posts';
         Libraries::add('test_app', array('path' => $testApp));
         mkdir($testApp . $path, 0777, true);
         file_put_contents($testApp . $path . "/{$class}Controller.php", "<?php namespace test_app{$namespace};\n\n\t\t\t\tclass {$class}Controller extends \\lithium\\action\\Controller {\n\t\t\t\tpublic function index() {\n\t\t\t\t\treturn true;\n\t\t\t\t}}");
         Libraries::cache(false);
         $expected = "test_app{$namespace}\\{$class}Controller";
         $instance = Libraries::instance($dotsyntax, "Posts", array('library' => 'test_app'));
         $result = get_class($instance);
         $this->assertEqual($expected, $result, "{$path} did not work");
     }
     $this->_cleanUp();
 }
開發者ID:rmarscher,項目名稱:lithium,代碼行數:20,代碼來源:LibrariesTest.php

示例7: testRunGroupForTestAppModel

 public function testRunGroupForTestAppModel()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/test_app';
     mkdir($testApp);
     Libraries::add('test_app', array('path' => $testApp));
     mkdir($testApp . '/tests/cases/models', 0777, true);
     file_put_contents($testApp . '/tests/cases/models/UserTest.php', "<?php namespace test_app\\tests\\cases\\models;\n\n\t\t\tclass UserTest extends \\lithium\\test\\Unit { public function testMe() {\n\t\t\t\t\$this->assertTrue(true);\n\t\t\t}}");
     Libraries::cache(false);
     $group = new Group(array('data' => array('\\test_app\\tests\\cases')));
     $expected = array('test_app\\tests\\cases\\models\\UserTest');
     $result = $group->to('array');
     $this->assertEqual($expected, $result);
     $expected = 'pass';
     $result = $group->tests()->run();
     $this->assertEqual($expected, $result[0][0]['result']);
     Libraries::cache(false);
     $this->_cleanUp();
 }
開發者ID:newmight2015,項目名稱:Blockchain-2,代碼行數:18,代碼來源:GroupTest.php

示例8: testCaseSensitivePathLookups

 public function testCaseSensitivePathLookups()
 {
     Libraries::cache(false);
     $library = Libraries::get('lithium');
     $base = $library['path'] . '/';
     $expected = $base . 'template/view.php';
     $result = Libraries::path('\\lithium\\template\\view');
     $this->assertEqual($expected, $result);
     $result = Libraries::path('lithium\\template\\view');
     $this->assertEqual($expected, $result);
     $expected = $base . 'template/View.php';
     $result = Libraries::path('\\lithium\\template\\View');
     $this->assertEqual($expected, $result);
     $result = Libraries::path('lithium\\template\\View');
     $this->assertEqual($expected, $result);
     $expected = $base . 'template/view';
     $result = Libraries::path('\\lithium\\template\\view', array('dirs' => true));
     $this->assertEqual($expected, $result);
     $result = Libraries::path('lithium\\template\\view', array('dirs' => true));
     $this->assertEqual($expected, $result);
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:21,代碼來源:LibrariesTest.php

示例9: array

use lithium\storage\Cache;
use lithium\core\Libraries;
use lithium\action\Dispatcher;
use lithium\storage\cache\adapter\Apc;
if (PHP_SAPI === 'cli') {
    return;
}
/**
 * If APC is not available and the cache directory is not writeable, bail out. This block should be
 * removed post-install, and the cache should be configured with the adapter you plan to use.
 */
if (!($apcEnabled = Apc::enabled()) && !is_writable(LITHIUM_APP_PATH . '/resources/tmp/cache')) {
    return;
}
if ($apcEnabled) {
    $default = array('adapter' => 'lithium\\storage\\cache\\adapter\\Apc');
} else {
    $default = array('adapter' => 'lithium\\storage\\cache\\adapter\\File', 'strategies' => array('Serializer'));
}
Cache::config(compact('default'));
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
    if ($cache = Cache::read('default', 'core.libraries')) {
        $cache = (array) $cache + Libraries::cache();
        Libraries::cache($cache);
    }
    $result = $chain->next($self, $params, $chain);
    if ($cache != Libraries::cache()) {
        Cache::write('default', 'core.libraries', Libraries::cache(), '+1 day');
    }
    return $result;
});
開發者ID:nervetattoo,項目名稱:li3_start,代碼行數:31,代碼來源:cache.php


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