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


PHP Cache::factory方法代碼示例

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


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

示例1: setUp

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->clearRegistry();
     $this->_cache = Cache\Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => sys_get_temp_dir()));
     Currency\Currency::setCache($this->_cache);
     $this->helper = new Helper\Currency('de_AT');
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:13,代碼來源:CurrencyTest.php

示例2: setUp

    public function setUp($notag = false)
    {
        $this->mkdir();
        $this->_cache_dir = $this->mkdir();
        @mkdir($this->_cache_dir.'/tags');

        $this->_innerCache = Cache\Cache::factory('Core','File',
            array('automatic_serialization'=>true), array('cache_dir'=>$this->_cache_dir.'/tags')
        );
        $this->_instance = new Cache\Backend\StaticBackend(array(
            'public_dir' => $this->_cache_dir,
            'tag_cache' => $this->_innerCache
        ));

        $logger = new \Zend\Log\Logger(new \Zend\Log\Writer\Null());
        $this->_instance->setDirectives(array('logger' => $logger));

        $this->_requestUriOld =
            isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null;
        $_SERVER['REQUEST_URI'] = '/foo';

        $this->_instance->setDirectives(array('logging' => true));

        $this->_instance->save('bar : data to cache', bin2hex('/bar'), array('tag3', 'tag4'));
        $this->_instance->save('bar2 : data to cache', bin2hex('/bar2'), array('tag3', 'tag1'));
        $this->_instance->save('bar3 : data to cache', bin2hex('/bar3'), array('tag2', 'tag3'));
    }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:27,代碼來源:StaticBackendTest.php

示例3: setUp

 public function setUp()
 {
     $this->originalTimezone = date_default_timezone_get();
     date_default_timezone_set('Europe/Paris');
     $this->_cache = Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/../_files/'));
     DateObjectTestHelper::setOptions(array('cache' => $this->_cache));
 }
開發者ID:stunti,項目名稱:zf2,代碼行數:7,代碼來源:DateObjectTest.php

示例4: setUp

 public function setUp()
 {
     $this->_cache = Cache::factory('Core', 'File',
              array('lifetime' => 1, 'automatic_serialization' => true),
              array('cache_dir' => __DIR__ . '/../../_files/'));
     Cldr::setCache($this->_cache);
 }
開發者ID:rukavina,項目名稱:zf2,代碼行數:7,代碼來源:CldrTest.php

示例5: _getSSObject

 /**
  * Enter description here...
  *
  * @return \Zend\Service\SlideShare
  */
 protected function _getSSObject()
 {
     $ss = new SlideShareService(TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY, TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET, TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD, TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID);
     $cache = Cache::factory('Core', 'File', array('lifetime' => 0, 'automatic_serialization' => true), array('cache_dir' => __DIR__ . "/_files"));
     $ss->setCacheObject($cache);
     return $ss;
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:12,代碼來源:SlideShareTest.php

示例6: testSetDefaultMetadataCache

 /**
  * @group ZF-10033
  */
 public function testSetDefaultMetadataCache()
 {
     $cache = \Zend\Cache\Cache::factory('Core', 'BlackHole', array('lifetime' => 120, 'automatic_serialization' => true));
     $config = array('adapter' => 'Pdo\\Sqlite', 'params' => array('dbname' => ':memory:'), 'defaultMetadataCache' => $cache);
     $resource = new DbResource($config);
     $resource->init();
     $this->assertInstanceOf('Zend\\Cache\\Frontend', \Zend\Db\Table\AbstractTable::getDefaultMetadataCache());
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:11,代碼來源:DbTest.php

示例7: setUp

 public function setUp()
 {
     $this->_cache_dir = $this->mkdir();
     $this->_cache = Cache\Cache::factory(
         'Core', 'File',
         array('automatic_serialization'=>true),
         array('cache_dir'=>$this->_cache_dir)
     );
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:9,代碼來源:ManagerTest.php

示例8: setUp

 public function setUp()
 {
     $this->_locale = setlocale(LC_ALL, 0);
     setlocale(LC_ALL, 'de');
     $this->_cache = Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => __DIR__ . '/../_files/'));
     LocaleTestHelper::resetObject();
     LocaleTestHelper::setCache($this->_cache);
     putenv("HTTP_ACCEPT_LANGUAGE=,de,en-UK-US;q=0.5,fr_FR;q=0.2");
 }
開發者ID:alab1001101,項目名稱:zf2,代碼行數:9,代碼來源:LocaleTest.php

示例9: setUp

 public function setUp()
 {
     $this->_locale = setlocale(LC_ALL, 0);
     setlocale(LC_ALL, 'de');
     $this->_cache = Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => __DIR__ . '/../_files/'));
     LocaleTestHelper::resetObject();
     LocaleTestHelper::setCache($this->_cache);
     // compatibilityMode is true until 1.8 therefor we have to change it
     LocaleTestHelper::$compatibilityMode = false;
     putenv("HTTP_ACCEPT_LANGUAGE=,de,en-UK-US;q=0.5,fr_FR;q=0.2");
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:11,代碼來源:LocaleTest.php

示例10: setUp

 public function setUp()
 {
     $cache = Cache\Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/_files/'));
     Currency\Currency::setCache($cache);
 }
開發者ID:stunti,項目名稱:zf2,代碼行數:5,代碼來源:CurrencyTest.php

示例11: testBackendBadParam

 public function testBackendBadParam()
 {
     Cache\Cache::factory('Output', 'badBackend', array(), array('badParam' => true));
 }
開發者ID:rexmac,項目名稱:zf2,代碼行數:4,代碼來源:FactoryException.php

示例12: getCacheObject

    /**
     * Gets the Zend\Cache object which will be used to cache API queries. If no cache object
     * was previously set the the default will be used (Filesystem caching in /tmp with a life
     * time of 43200 seconds)
     *
     * @return Zend\Cache\Frontend\Core The object used in caching
     */
    public function getCacheObject()
    {

        if(!($this->_cacheobject instanceof Frontend\Core)) {
            $cache = \Zend\Cache\Cache::factory('Core', 'File', array('lifetime' => 43200,
                                                               'automatic_serialization' => true),
                                                         array('cache_dir' => '/tmp'));

            $this->setCacheObject($cache);
        }

        return $this->_cacheobject;
    }
開發者ID:niallmccrudden,項目名稱:zf2,代碼行數:20,代碼來源:SlideShare.php

示例13: _getCacheNowrite

 /**
  * Returns a clean Zend_Cache_Core with File backend
  *
  * @return Zend_Cache_Core
  */
 protected function _getCacheNowrite()
 {
     /**
      * @see Zend_Cache
      */
     $folder = __DIR__ . DIRECTORY_SEPARATOR . '../_files' . DIRECTORY_SEPARATOR . 'nofiles';
     if (!file_exists($folder)) {
         mkdir($folder, 0777);
     }
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $folder, 'file_name_prefix' => 'Zend_Db_Table_TestCommon');
     $cacheFrontend = Cache\Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     $cacheFrontend->clean(Cache\Cache::CLEANING_MODE_ALL);
     rmdir($folder);
     return $cacheFrontend;
 }
開發者ID:rexmac,項目名稱:zf2,代碼行數:21,代碼來源:AbstractTest.php

示例14: getCache

 /**
  * Fetch the named cache object, or instantiate and return a cache object
  * using a named configuration template
  *
  * @param  string $name
  * @return \Zend\Cache\Core
  */
 public function getCache($name)
 {
     if (isset($this->_caches[$name])) {
         return $this->_caches[$name];
     }
     if (isset($this->_optionTemplates[$name])) {
         if ($name == self::PAGECACHE && (!isset($this->_optionTemplates[$name]['backend']['options']['tag_cache']) || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Core)) {
             $this->_optionTemplates[$name]['backend']['options']['tag_cache'] = $this->getCache(self::PAGETAGCACHE);
         }
         $this->_caches[$name] = Cache::factory($this->_optionTemplates[$name]['frontend']['name'], $this->_optionTemplates[$name]['backend']['name'], isset($this->_optionTemplates[$name]['frontend']['options']) ? $this->_optionTemplates[$name]['frontend']['options'] : array(), isset($this->_optionTemplates[$name]['backend']['options']) ? $this->_optionTemplates[$name]['backend']['options'] : array(), isset($this->_optionTemplates[$name]['frontend']['customFrontendNaming']) ? $this->_optionTemplates[$name]['frontend']['customFrontendNaming'] : false, isset($this->_optionTemplates[$name]['backend']['customBackendNaming']) ? $this->_optionTemplates[$name]['backend']['customBackendNaming'] : false, isset($this->_optionTemplates[$name]['frontendBackendAutoload']) ? $this->_optionTemplates[$name]['frontendBackendAutoload'] : false);
         return $this->_caches[$name];
     }
 }
開發者ID:heiglandreas,項目名稱:zf2,代碼行數:20,代碼來源:Manager.php

示例15: testSetDefaultMetadataCache

 /**
  * @group ZF-10049
  */
 public function testSetDefaultMetadataCache()
 {
     $cache = Cache::factory('Core', 'BlackHole', array('lifetime' => 120, 'automatic_serialization' => true));
     $options = $this->_dbOptions;
     $options['defaultMetadataCache'] = $cache;
     $resource = new MultidbResource($options);
     $resource->init();
     $this->assertType('Zend\\Cache\\Frontend\\Core', DBTable::getDefaultMetadataCache());
 }
開發者ID:heiglandreas,項目名稱:zf2,代碼行數:12,代碼來源:MultidbTest.php


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