当前位置: 首页>>代码示例>>PHP>>正文


PHP Cache::engine方法代码示例

本文整理汇总了PHP中Cache::engine方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::engine方法的具体用法?PHP Cache::engine怎么用?PHP Cache::engine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cache的用法示例。


在下文中一共展示了Cache::engine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testInitSettings

 function testInitSettings()
 {
     Cache::engine('File', array('path' => TMP . 'tests'));
     $settings = Cache::settings();
     $expecting = array('duration' => 3600, 'probability' => 100, 'path' => TMP . 'tests', 'prefix' => 'cake_', 'lock' => false, 'serialize' => true);
     $this->assertEqual($settings, $expecting);
 }
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:7,代码来源:cache.test.php

示例2: skip

 function skip()
 {
     $skip = true;
     if ($result = Cache::engine('Apc')) {
         $skip = false;
     }
     $this->skipif($skip, 'APCEngineTest not implemented');
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:8,代码来源:apc.test.php

示例3: skip

 /**
  * skip method
  *
  * @access public
  * @return void
  */
 function skip()
 {
     $skip = true;
     if (Cache::engine('Apc')) {
         $skip = false;
     }
     $this->skipif($skip, 'Apc is not installed or configured properly');
 }
开发者ID:jerzzz777,项目名称:cake-cart,代码行数:14,代码来源:apc.test.php

示例4: skip

 /**
  * skip method
  *
  * @access public
  * @return void
  */
 function skip()
 {
     $skip = true;
     if ($result = Cache::engine('Xcache')) {
         $skip = false;
     }
     $this->skipIf($skip, '%s Xcache is not installed or configured properly');
 }
开发者ID:masayukiando,项目名称:googlemap-search_ActionScript3.0,代码行数:14,代码来源:xcache.test.php

示例5: testWriteQuotedString

 /**
  * testWriteQuotedString method
  *
  * @access public
  * @return void
  */
 function testWriteQuotedString()
 {
     Cache::engine('File', array('path' => TMP . 'tests'));
     Cache::write('App.doubleQuoteTest', '"this is a quoted string"');
     $this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
     Cache::write('App.singleQuoteTest', "'this is a quoted string'");
     $this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
     Cache::engine('File', array('isWindows' => true, 'path' => TMP . 'tests'));
     $this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"');
     Cache::write('App.singleQuoteTest', "'this is a quoted string'");
     $this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'");
 }
开发者ID:uuking,项目名称:wildflower,代码行数:18,代码来源:file.test.php

示例6: testExpiry

 /**
  * testExpiry method
  *
  * @access public
  * @return void
  */
 function testExpiry()
 {
     sleep(2);
     $result = Cache::read('test');
     $this->assertFalse($result);
     $data = 'this is a test of the emergency broadcasting system';
     $result = Cache::write('other_test', $data, 1);
     $this->assertTrue($result);
     sleep(2);
     $result = Cache::read('other_test');
     $this->assertFalse($result);
     $data = 'this is a test of the emergency broadcasting system';
     $result = Cache::write('other_test', $data, "+1 second");
     $this->assertTrue($result);
     sleep(2);
     $result = Cache::read('other_test');
     $this->assertFalse($result);
     $data = 'this is a test of the emergency broadcasting system';
     $result = Cache::write('other_test', $data);
     $this->assertTrue($result);
     $result = Cache::read('other_test');
     $this->assertEqual($result, $data);
     Cache::engine('Memcache', array('duration' => '+1 second'));
     sleep(2);
     $result = Cache::read('other_test');
     $this->assertFalse($result);
     Cache::engine('Memcache', array('duration' => 3600));
 }
开发者ID:quinns,项目名称:REST-API,代码行数:34,代码来源:memcache.test.php

示例7: testInitSettings

 /**
  * testInitSettings method
  *
  * @access public
  * @return void
  */
 function testInitSettings()
 {
     Cache::engine('File', array('path' => TMP . 'tests'));
     $settings = Cache::settings();
     $expecting = array('engine' => 'File', 'duration' => 3600, 'probability' => 100, 'path' => TMP . 'tests', 'prefix' => 'cake_', 'lock' => false, 'serialize' => true, 'isWindows' => DIRECTORY_SEPARATOR == '\\');
     $this->assertEqual($settings, $expecting);
     Cache::engine('File');
 }
开发者ID:acerato,项目名称:cntcetp,代码行数:14,代码来源:cache.test.php

示例8: load

 /**
 		Load and configure backend; Auto-detect if argument is FALSE
 			@return string|void
 			@param $dsn string|FALSE
 	**/
 static function load($dsn = FALSE)
 {
     if (is_bool($dsn)) {
         // Auto-detect backend
         $ext = array_map('strtolower', get_loaded_extensions());
         $grep = preg_grep('/^(apc|xcache|shmop)/', $ext);
         $dsn = $grep ? current($grep) : 'folder=cache/';
     }
     $parts = explode('=', $dsn);
     if (!preg_match('/apc|xcache|shmop|folder|memcache/', $parts[0])) {
         return;
     }
     self::$engine = array('type' => $parts[0], 'data' => NULL);
     self::$ref = NULL;
     if ($parts[0] == 'shmop') {
         $self = __CLASS__;
         self::$ref = self::mutex(function () use($self) {
             $ref = @shmop_open($ftok = ftok(__FILE__, 'C'), 'c', 0644, $self::bytes(ini_get('memory_limit')));
             if ($ref && !unserialize(trim(shmop_read($ref, 0, 0xffff)))) {
                 shmop_write($ref, serialize(array()) . chr(0), 0);
             }
             return $ref;
         }, self::$vars['TEMP'] . $_SERVER['SERVER_NAME']);
         if (!self::$ref) {
             return self::load('folder=cache/');
         }
     } elseif (isset($parts[1])) {
         if ($parts[0] == 'memcache') {
             if (extension_loaded('memcache')) {
                 foreach (self::split($parts[1]) as $server) {
                     $parts = explode(':', $server);
                     if (count($parts) < 2) {
                         $host = $parts[0];
                         $port = 11211;
                     } else {
                         list($host, $port) = $parts;
                     }
                     if (!self::$ref) {
                         self::$ref = @memcache_connect($host, $port);
                     } else {
                         memcache_add_server(self::$ref, $host, $port);
                     }
                 }
             } else {
                 return self::$engine = NULL;
             }
         } elseif ($parts[0] == 'folder') {
             if (!is_dir($parts[1]) && !@mkdir($parts[1], 0755, TRUE)) {
                 return self::$engine = NULL;
             }
             self::$ref = $parts[1];
         }
     }
     return $dsn;
 }
开发者ID:rhaggard,项目名称:php-starter-template,代码行数:60,代码来源:base.php

示例9: testWriteEmptyValues

 /**
  * testWriteEmptyValues method
  *
  * @access public
  * @return void
  */
 function testWriteEmptyValues()
 {
     return;
     Cache::engine('File', array('path' => TMP . 'tests'));
     Cache::write('App.falseTest', false);
     $this->assertIdentical(Cache::read('App.falseTest'), false);
     Cache::write('App.trueTest', true);
     $this->assertIdentical(Cache::read('App.trueTest'), true);
     Cache::write('App.nullTest', null);
     $this->assertIdentical(Cache::read('App.nullTest'), null);
     Cache::write('App.zeroTest', 0);
     $this->assertIdentical(Cache::read('App.zeroTest'), 0);
     Cache::write('App.zeroTest2', '0');
     $this->assertIdentical(Cache::read('App.zeroTest2'), '0');
 }
开发者ID:BGCX067,项目名称:fambom-svn-to-git,代码行数:21,代码来源:cache.test.php

示例10: testEngineFailure

 /**
  * Test engine method.
  *
  *  Failure.
  *
  * @return void
  */
 public function testEngineFailure()
 {
     $actual = Cache::engine('some_config_that_does_not_exist');
     $this->assertNull($actual);
     Configure::write('Cache.disable', true);
     $actual = Cache::engine();
     $this->assertNull($actual);
 }
开发者ID:hodrigohamalho,项目名称:cakephp-ex,代码行数:15,代码来源:CacheTest.php

示例11: testClear

 function testClear()
 {
     $data = 'this is a test of the emergency broadcasting system';
     $write = Cache::write('seriailze_test1', $data, 1);
     $write = Cache::write('seriailze_test2', $data, 1);
     $write = Cache::write('seriailze_test3', $data, 1);
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test1'));
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test2'));
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test3'));
     Cache::engine('File', array('duration' => 1));
     sleep(4);
     $result = Cache::clear(true);
     $this->assertTrue($result);
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test1'));
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test2'));
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test3'));
     $data = 'this is a test of the emergency broadcasting system';
     $write = Cache::write('seriailze_test1', $data, 1);
     $write = Cache::write('seriailze_test2', $data, 1);
     $write = Cache::write('seriailze_test3', $data, 1);
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test1'));
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test2'));
     $this->assertTrue(file_exists(CACHE . 'cake_seriailze_test3'));
     $result = Cache::clear();
     $this->assertTrue($result);
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test1'));
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test2'));
     $this->assertFalse(file_exists(CACHE . 'cake_seriailze_test3'));
 }
开发者ID:kaz0636,项目名称:openflp,代码行数:29,代码来源:file.test.php


注:本文中的Cache::engine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。