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


PHP Kohana::cache方法代码示例

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


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

示例1: configure_environment

 /**
  * Configures the environment for testing
  *
  * Does the following:
  *
  * * Loads the phpunit framework (for the web ui)
  * * Restores exception phpunit error handlers (for cli)
  * * registeres an autoloader to load test files
  */
 public static function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE)
 {
     restore_exception_handler();
     restore_error_handler();
     spl_autoload_register(array('Unittest_tests', 'autoload'));
     Unittest_tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:16,代码来源:Tests.php

示例2: delete

 /**
  * Delete a cached fragment.
  *
  * @param   string   fragment name
  * @return  void
  */
 public static function delete($name)
 {
     // Set the cache key name
     $cache_key = 'Fragment::cache(' . $name . ')';
     // Invalid the cache
     Kohana::cache($cache_key, NULL, -3600);
 }
开发者ID:Normull,项目名称:core,代码行数:13,代码来源:fragment.php

示例3: configure_enviroment

 /**
  * Configures the enviroment for testing
  *
  * Does the following:
  *
  * * Loads the phpunit framework (for the web ui)
  * * Restores exception phpunit error handlers (for cli)
  * * registeres an autoloader to load test files
  */
 public static function configure_enviroment($do_whitelist = TRUE, $do_blacklist = TRUE)
 {
     if (!class_exists('PHPUnit_Util_Filter', FALSE)) {
         // Make sure the PHPUnit classes are available
         require_once 'PHPUnit/Framework.php';
     }
     if (Kohana::$is_cli) {
         restore_exception_handler();
         restore_error_handler();
     }
     spl_autoload_register(array('Kohana_Tests', 'autoload'));
     Kohana_Tests::$cache = ($cache = Kohana::cache('phpunit_whitelist_cache')) === NULL ? array() : $cache;
     $config = Kohana::config('phpunit');
     if ($do_whitelist and $config->use_whitelist) {
         self::whitelist();
     }
     if ($do_blacklist and count($config['blacklist'])) {
         foreach ($config->blacklist as $item) {
             if (is_dir($item)) {
                 PHPUnit_Util_Filter::addDirectoryToFilter($item);
             } else {
                 PHPUnit_Util_Filter::addFileToFilter($item);
             }
         }
     }
 }
开发者ID:kierangraham,项目名称:unittest,代码行数:35,代码来源:tests.php

示例4: getResponse

 private static function getResponse($aURL) {
     Retio_Bitly::$_cacheKey = Retio_Bitly::CACHE_PREFIX . substr(md5(Retio_Bitly::$_url), 0, 10) .'_'. Retio_Bitly::$_action;
     
     $data                   = Kohana::cache(Retio_Bitly::$_cacheKey);
     if ($data === NULL) {
         try {
             $rData   = Request::factory($aURL)->execute()->body();
             
             switch (Retio_Bitly::$_config->format) {
                 case 'json':
                     $object = json_decode($rData);
                     $data   = ($object->status_code === 200) ? $object->data : NULL;
                 break;
                 case 'xml':
                     $object = simplexml_load_string($rData);
                     $data   = ($object->status_code === 200) ? $object->data : NULL;
                 break;
                 case 'txt':
                     $data = trim($rData);
                 break;
             }
             
             if ($data != NULL)
                 Kohana::cache(Retio_Bitly::$_cacheKey, $data, Retio_Bitly::CACHE_TIME);
             
         } catch (Exception $e) {
             return FALSE;
         }
     }
     return $data;
 }
开发者ID:retio,项目名称:Retio-Bitly,代码行数:31,代码来源:bitly.php

示例5: execute

 public function execute($address)
 {
     Geocode_Yahoo::$_cacheKey = Geocode_Yahoo::CACHE_PREFIX . md5($address);
     $data = Kohana::cache(Geocode_Yahoo::$_cacheKey);
     if ($data === NULL) {
         try {
             $request = Geocode_Yahoo::API_URL . '?q=' . urlencode($address) . '&appid=' . $this->api_key . '&flags=' . $this->flags . '&locale=' . $this->locale;
             $sData = Request::factory($request)->execute()->body();
             $data = unserialize($sData);
             if ($data['ResultSet']['Error'] === 0 && $data['ResultSet']['Found'] > 0) {
                 $resultsArray = array();
                 foreach ($data['ResultSet']['Result'] as $k => $result) {
                     $resultsArray[] = array('lat' => (double) $result['latitude'], 'lng' => (double) $result['longitude'], 'zip' => (string) $result['postal'], 'city' => (string) $result['city'], 'state' => (string) $result['state'], 'country' => (string) $result['countrycode'], 'street_house' => (string) $result['street'] . ' ' . $result['house']);
                 }
                 $data = array('dataCount' => $data['ResultSet']['Found'], 'dataArray' => $resultsArray);
                 Kohana::cache(Geocode_Yahoo::$_cacheKey, $data, Geocode_Yahoo::CACHE_TIME);
             } else {
                 return FALSE;
             }
         } catch (Exception $e) {
             return FALSE;
         }
     }
     return $data;
 }
开发者ID:retio,项目名称:kohana-geocode,代码行数:25,代码来源:yahoo.php

示例6: action_load

 /**
  * Load pages from database, static view files,
  * or display 404 error page.
  */
 public function action_load()
 {
     Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Cms_Page::action_load');
     $page = Request::instance()->param('page');
     $page = Security::xss_clean($page);
     // Check if page is in cache
     if (Kohana::$caching === TRUE and $file = Kohana::cache('page_' . $page)) {
         $this->template->content = $file;
         return;
     }
     // Default values
     $contents = NULL;
     $found = FALSE;
     // Check if page is in database
     $db = DB::select('title', 'text')->from('pages')->where('slug', '=', $page)->execute();
     if ($db->count() == 1) {
         $contents = $db->current();
         $contents = $contents['text'];
         $found = TRUE;
     } else {
         if (Kohana::find_file('views', 'static/' . $page)) {
             $contents = new View('static/' . $page);
             $found = TRUE;
         } else {
             Kohana::$log->add(Kohana::ERROR, 'Page controller error loading non-existent page, ' . $page);
             $contents = new View('errors/404');
         }
     }
     if (Kohana::$caching === TRUE and $found) {
         Kohana::cache('page_' . $page, $contents);
     }
     $this->template->content = $contents;
 }
开发者ID:vimofthevine,项目名称:kohana-cms,代码行数:37,代码来源:page.php

示例7: get_data

 /**
  * A slightly modified method for fetching weather results,
  * found at http://www.web-spirit.de/webdesign-tutorial/9/Wetter-auf-eigener-Website-mit-Google-Weather-API
  * @param  string $city
  * @param  string $language
  * @return array
  * @uses   Kohana::cache
  */
 public static function get_data($city, $language = 'de')
 {
     $aReturn = Kohana::cache('weather-api', NULL, 3600);
     if ($aReturn === NULL) {
         $aReturn = array();
         $oXml = simplexml_load_string(utf8_encode(file_get_contents('http://www.google.com/ig/api?weather=' . $city . '&hl=' . $language)));
         $aReturn['city'] = (string) $oXml->weather->forecast_information->city->attributes()->data;
         $aReturn['date'] = (string) $oXml->weather->forecast_information->forecast_date->attributes()->data;
         $aReturn['time'] = (string) $oXml->weather->forecast_information->current_date_time->attributes()->data;
         $aReturn['now']['condition'] = (string) $oXml->weather->current_conditions->condition->attributes()->data;
         $aReturn['now']['temperature'] = (string) $oXml->weather->current_conditions->temp_c->attributes()->data;
         $aReturn['now']['humidity'] = (string) $oXml->weather->current_conditions->humidity->attributes()->data;
         $aReturn['now']['wind'] = (string) $oXml->weather->current_conditions->wind_condition->attributes()->data;
         $aReturn['now']['icon'] = str_replace('/ig/images/weather/', '', $oXml->weather->current_conditions->icon->attributes()->data);
         $i = 1;
         foreach ($oXml->weather->forecast_conditions as $oWeather) {
             $aReturn['days'][$i]['weekday'] = (string) $oWeather->day_of_week->attributes()->data;
             $aReturn['days'][$i]['condition'] = (string) $oWeather->condition->attributes()->data;
             $aReturn['days'][$i]['temperature_min'] = (string) $oWeather->low->attributes()->data;
             $aReturn['days'][$i]['temperature_max'] = (string) $oWeather->high->attributes()->data;
             $aReturn['days'][$i]['icon'] = str_replace('/ig/images/weather/', '', $oWeather->icon->attributes()->data);
             $i++;
         }
         // foreach
         Kohana::cache('weather-api', $aReturn);
     }
     // if
     return $aReturn;
 }
开发者ID:ragchuck,项目名称:ra-Log,代码行数:37,代码来源:gweather.php

示例8: configure_environment

 /**
  * Configures the environment for testing
  *
  * Does the following:
  *
  * * Loads the phpunit framework (for the web ui)
  * * Restores exception phpunit error handlers (for cli)
  * * registeres an autoloader to load test files
  */
 public static function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE)
 {
     // During a webui request we need to manually load PHPUnit
     if (!class_exists('PHPUnit_Util_Filter', FALSE) and !function_exists('phpunit_autoload')) {
         try {
             include_once 'PHPUnit/Autoload.php';
         } catch (ErrorException $e) {
             include_once 'PHPUnit/Framework.php';
         }
     }
     // Allow PHPUnit to handle exceptions and errors
     if (Kohana::$is_cli) {
         restore_exception_handler();
         restore_error_handler();
     }
     spl_autoload_register(array('Kohana_Tests', 'autoload'));
     Kohana_Tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache;
     // As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted
     self::$phpunit_v35 = function_exists('phpunit_autoload');
     $config = Kohana::config('unittest');
     if ($do_whitelist and $config->use_whitelist) {
         self::whitelist();
     }
     if ($do_blacklist and count($config['blacklist'])) {
         Kohana_Tests::blacklist($config->blacklist);
     }
 }
开发者ID:azuya,项目名称:Wi3,代码行数:36,代码来源:tests.php

示例9: configure_environment

 /**
  * Configures the environment for testing
  *
  * Does the following:
  *
  * * Loads the phpunit framework (for the web ui)
  * * Restores exception phpunit error handlers (for cli)
  * * registeres an autoloader to load test files
  */
 public static function configure_environment($do_whitelist = TRUE, $do_blacklist = TRUE)
 {
     restore_exception_handler();
     restore_error_handler();
     spl_autoload_register(array('Unittest_tests', 'autoload'));
     // As of PHPUnit v3.5 there are slight differences in the way files are black|whitelisted
     self::$phpunit_v35 = function_exists('phpunit_autoload');
     Unittest_tests::$cache = ($cache = Kohana::cache('unittest_whitelist_cache')) === NULL ? array() : $cache;
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:18,代码来源:tests.php

示例10: load_fixtures

 public static function load_fixtures()
 {
     $fixture = Functest_Fixture::instance();
     $import_sql = Kohana::cache(Functest_Tests::FIXTURE_CACHE);
     if ($import_sql) {
         $fixture->replace($import_sql);
     } else {
         $fixture->truncate_all();
         $fixture->execute_import_files(Functest_Tests::fixture_files());
         Kohana::cache(Functest_Tests::FIXTURE_CACHE, $fixture->dump(), Date::HOUR);
     }
 }
开发者ID:openbuildings,项目名称:functest,代码行数:12,代码来源:Tests.php

示例11: offsetExists

 public function offsetExists($group)
 {
     if (!parent::offsetExists($group)) {
         if (($config = Kohana::cache('kohana_config_' . $group)) === NULL) {
             // Load the configuration group
             $config = $this->load($group);
             // Cache the configuration
             Kohana::cache('kohana_config_' . $group, $config);
         }
         // Set the missing configuration
         $this->offsetSet($group, new Kohana_Config($config));
     }
     return TRUE;
 }
开发者ID:ukd1,项目名称:kohana,代码行数:14,代码来源:loader.php

示例12: action_cache

 public function action_cache($keyandext)
 {
     if (substr($keyandext, -3) == 'css') {
         $key = substr($keyandext, 0, -3);
         $this->request->headers['Content-Type'] = 'text/css';
     } elseif (substr($keyandext, -2) == 'js') {
         $key = substr($keyandext, 0, -2);
     } else {
         return;
     }
     $content = Kohana::cache($key);
     //$this->request->headers['Content-Type'] = 'application/javascript';
     $this->request->response = $content;
 }
开发者ID:glydetech,项目名称:ko3.xhtml,代码行数:14,代码来源:xhtml.php

示例13: execute

 public function execute()
 {
     if ($this->_is_cached === true) {
         $cache_key = 'REST-api-result' . $this->_url;
         if (($result = Kohana::cache($cache_key, NULL, $this->_cache_life)) !== NULL) {
             return $this->_as_object ? json_decode($result) : $result;
         } else {
             $result = $this->_execute_request($this->_url);
             Kohana::cache($cache_key, $result, $this->_cache_life);
             return $this->_as_object ? json_decode($result) : $result;
         }
     }
     // get data if caching is disabled
     $result = $this->_execute_request($this->_url);
     return $this->_as_object ? json_decode($result) : $result;
 }
开发者ID:ChrisCov,项目名称:HUKD,代码行数:16,代码来源:REST.php

示例14: __construct

 /**
  * Creates a new configuration object for the specified group. When caching
  * is enabled, Kohana_Config will attempt to load the group from the cache.
  *
  * @param   string   group name
  * @param   boolean  cache the group array
  * @return  void
  */
 public function __construct($group, $cache = TRUE)
 {
     // Set the configuration group name
     $this->_configuration_group = $group;
     if ($cache === FALSE) {
         // Load the configuration
         $config = Kohana_Config::load($group);
     } elseif (($config = Kohana::cache(self::CACHE_PREFIX . $group)) === NULL) {
         // Load the configuration, it has not been cached
         $config = Kohana_Config::load($group);
         // Create a cache of the configuration group
         Kohana::cache(self::CACHE_PREFIX . $group, $config);
     }
     // Load the array using the values as properties
     ArrayObject::__construct($config, ArrayObject::ARRAY_AS_PROPS);
 }
开发者ID:ukd1,项目名称:kohana,代码行数:24,代码来源:config.php

示例15: test_load_fixtures

 public function test_load_fixtures()
 {
     global $_functest_test_counter;
     $_functest_test_counter = 0;
     Kohana::cache(Functest_Tests::FIXTURE_CACHE, null, 0);
     Database::instance(Kohana::TESTING)->query(NULL, 'DELETE FROM table1');
     Functest_Tests::load_fixtures();
     $result = Database::instance(Kohana::TESTING)->query(Database::SELECT, 'SELECT * FROM table1');
     $expected = array(array('id' => 1, 'name' => 'test record'));
     $this->assertEquals(1, $_functest_test_counter);
     $this->assertEquals($expected, $result->as_array());
     Database::instance(Kohana::TESTING)->query(NULL, 'DELETE FROM table1');
     Functest_Tests::load_fixtures();
     $result = Database::instance(Kohana::TESTING)->query(Database::SELECT, 'SELECT * FROM table1');
     $this->assertEquals($expected, $result->as_array());
     $this->assertEquals(1, $_functest_test_counter, 'Should load the sql from the cache. so the counter is not incremented');
 }
开发者ID:openbuildings,项目名称:functest,代码行数:17,代码来源:TestsTest.php


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