当前位置: 首页>>代码示例>>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;未经允许,请勿转载。