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


PHP Cache::instance方法代码示例

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


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

示例1: start

 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
开发者ID:brendo,项目名称:symphony-3,代码行数:29,代码来源:class.session.php

示例2: index

 public function index($feedtype = 'rss2')
 {
     if (!Kohana::config('settings.allow_feed')) {
         throw new Kohana_404_Exception();
     }
     if ($feedtype != 'atom' and $feedtype != 'rss2') {
         throw new Kohana_404_Exception();
     }
     // How Many Items Should We Retrieve?
     $limit = (isset($_GET['l']) and !empty($_GET['l']) and (int) $_GET['l'] <= 200) ? (int) $_GET['l'] : 20;
     // Start at which page?
     $page = (isset($_GET['p']) and !empty($_GET['p']) and (int) $_GET['p'] >= 1) ? (int) $_GET['p'] : 1;
     $page_position = $page == 1 ? 0 : $page * $limit;
     // Query position
     $site_url = url::base();
     // Cache the Feed with subdomain in the cache name if mhi is set
     $subdomain = '';
     if (substr_count($_SERVER["HTTP_HOST"], '.') > 1 and Kohana::config('config.enable_mhi') == TRUE) {
         $subdomain = substr($_SERVER["HTTP_HOST"], 0, strpos($_SERVER["HTTP_HOST"], '.'));
     }
     $cache = Cache::instance();
     $feed_items = $cache->get($subdomain . '_feed_' . $limit . '_' . $page);
     if ($feed_items == NULL) {
         // Cache is Empty so Re-Cache
         $incidents = ORM::factory('incident')->where('incident_active', '1')->orderby('incident_date', 'desc')->limit($limit, $page_position)->find_all();
         $items = array();
         foreach ($incidents as $incident) {
             $categories = array();
             foreach ($incident->category as $category) {
                 $categories[] = (string) $category->category_title;
             }
             $item = array();
             $item['id'] = $incident->id;
             $item['title'] = $incident->incident_title;
             $item['link'] = $site_url . 'reports/view/' . $incident->id;
             $item['description'] = $incident->incident_description;
             $item['date'] = $incident->incident_date;
             $item['categories'] = $categories;
             if ($incident->location_id != 0 and $incident->location->longitude and $incident->location->latitude) {
                 $item['point'] = array($incident->location->latitude, $incident->location->longitude);
                 $items[] = $item;
             }
         }
         $cache->set($subdomain . '_feed_' . $limit . '_' . $page, $items, array('feed'), 3600);
         // 1 Hour
         $feed_items = $items;
     }
     $feedpath = $feedtype == 'atom' ? 'feed/atom/' : 'feed/';
     header('Content-Type: application/' . ($feedtype == 'atom' ? 'atom' : 'rss') . '+xml; charset=utf-8');
     $view = new View('feed/' . $feedtype);
     $view->feed_title = Kohana::config('settings.site_name');
     $view->site_url = $site_url;
     $view->georss = 1;
     // this adds georss namespace in the feed
     $view->feed_url = $site_url . $feedpath;
     $view->feed_date = gmdate("D, d M Y H:i:s T", time());
     $view->feed_description = Kohana::lang('ui_admin.incident_feed') . ' ' . Kohana::config('settings.site_name');
     $view->items = $feed_items;
     $view->render(TRUE);
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:60,代码来源:feed.php

示例3: getSeriesPinyin

 public static function getSeriesPinyin()
 {
     $redis = Cache::instance('redis');
     $cache_key = '_ALL_SERIES_PINYIN_';
     $data = $redis->get($cache_key);
     if (empty($data)) {
         $m_brand = Model::factory('auto_series');
         $data = $m_brand->getAll('', 'id,pinyin')->as_array();
         $data = array_column($data, 'pinyin', 'id');
         $data = array_map(function ($v) {
             return preg_replace('/[^0-9a-z]/', '', strtolower($v));
         }, $data);
         $tmp = array();
         foreach ($data as $id => $pinyin) {
             if (isset($tmp[$pinyin])) {
                 $tmp[$pinyin] += 1;
                 $data[$id] = $pinyin . $tmp[$pinyin];
             } else {
                 $tmp[$pinyin] = 1;
             }
         }
         $redis->setex($cache_key, 86400, json_encode($data));
     } else {
         $data = json_decode($data, true);
     }
     return $data;
 }
开发者ID:andygoo,项目名称:cms,代码行数:27,代码来源:SEO.php

示例4: create

 public static function create()
 {
     if (!is_object(self::$instance)) {
         self::$instance = new Cache();
     }
     return self::$instance;
 }
开发者ID:Anon215,项目名称:movim,代码行数:7,代码来源:Cache.php

示例5: action_clean

 /**
  * 更新首页,公共社区,图书馆首页
  */
 public function action_clean()
 {
     $cid = (int) $this->getQuery('cid');
     switch ($cid) {
         case 1:
             @unlink(DOCROOT . 'cache/index.html');
             shell_exec('. /server/wal8/www/bin/clearcache.sh http://www.wal8.com/cache/index.html');
             break;
         case 2:
             @unlink(DOCROOT . 'cache/pic.html');
             shell_exec('. /server/wal8/www/bin/clearcache.sh http://www.wal8.com/cache/pic.html');
             break;
             break;
         case 3:
             @unlink(DOCROOT . 'cache/book.html');
             shell_exec('. /server/wal8/www/bin/clearcache.sh http://www.wal8.com/cache/book.html');
             break;
             break;
         case 4:
             Cache::instance()->delete();
             break;
             break;
     }
     $links[] = array('text' => '缓存状况', 'href' => '/admin/cache');
     $this->show_message('缓存更新成功', 1, $links, true);
     $this->auto_render = false;
 }
开发者ID:BGCX261,项目名称:zhongyycode-svn-to-git,代码行数:30,代码来源:cache.php

示例6: getInstance

 /**
  * 静态方法,返回数据库连接实例
  *
  * @return Cache
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Cache();
     }
     return self::$instance;
 }
开发者ID:LockGit,项目名称:emlog,代码行数:12,代码来源:cache.php

示例7: action_index

 public function action_index()
 {
     $select = DB::select()->from('imgup_config')->order_by('id', 'DESC')->limit('1')->execute()->current();
     $this->template->rows = $select;
     if ($this->isPost()) {
         $post = Validate::factory($this->getPost())->filter(TRUE, 'trim')->rule('allowed_ext', 'not_empty')->rule('admin_email', 'not_empty')->rule('max_upload', 'not_empty')->rule('max_upload', 'numeric')->rule('unit', 'not_empty');
         if ($post->check()) {
             $id = (int) $this->getPost('id');
             $max_B = $this->getPost('max_upload') . ':' . $this->getPost('unit');
             $set = array('allowed_ext' => trim($this->getPost('allowed_ext')), 'admin_email' => $this->getPost('admin_email'), 'max_upload' => $max_B, 'tmp_message_top' => trim($this->getPost('tmp_message_top')), 'marquee_message' => trim($this->getPost('marquee_message')), 'show_top' => (int) $this->getPost('show_top'));
             if ($id > 0) {
                 DB::update('imgup_config')->set($set)->where('id', '=', $id)->execute();
                 Cache::instance()->delete('sys_configs');
                 @unlink(DOCROOT . 'cache/index.html');
                 @shell_exec('. /server/wal8/www/bin/clearcache.sh http://www.wal8.com/cache/index.html');
                 $links[] = array('text' => '返回列表', 'href' => '/admin/system');
                 $this->show_message('修改资料成功', 1, $links, true);
             }
         } else {
             // 校验失败,获得错误提示
             $str = '';
             $this->template->registerErr = $errors = $post->errors('admin/module');
             foreach ($errors as $item) {
                 $str .= $item . '<br>';
             }
             $this->show_message($str);
         }
     }
 }
开发者ID:BGCX261,项目名称:zhongyycode-svn-to-git,代码行数:29,代码来源:system.php

示例8: system_metadata

 /**
  * Retrieves the metadata for all the supported spatial reference systems.
  *
  * @param boolean $refresh Set to true to force a full refresh, otherwise the result is cached.
  */
 public static function system_metadata($refresh = false)
 {
     $cacheId = 'spatial-ref-systems';
     if ($refresh) {
         $cache = Cache::instance();
         $cache->delete($cacheId);
         self::$system_metadata = false;
     }
     if (self::$system_metadata === false) {
         $latlong_systems = Kohana::config('sref_notations.lat_long_systems');
         $cache = Cache::instance();
         if ($cached = $cache->get($cacheId)) {
             self::$system_metadata = $cached;
         } else {
             self::$system_metadata = array();
             // fetch any systems that are just declared as srids, with no notation module required
             foreach (Kohana::config('sref_notations.sref_notations') as $code => $title) {
                 self::$system_metadata["EPSG:{$code}"] = array('title' => $title, 'srid' => $code, 'treat_srid_as_x_y_metres' => !isset($latlong_systems[$code]));
             }
             // Now look for any modules which extend the sref systems available
             foreach (Kohana::config('config.modules') as $path) {
                 $plugin = basename($path);
                 if (file_exists("{$path}/plugins/{$plugin}.php")) {
                     require_once "{$path}/plugins/{$plugin}.php";
                     if (function_exists($plugin . '_sref_systems')) {
                         $metadata = call_user_func($plugin . '_sref_systems');
                         self::$system_metadata = array_merge(self::$system_metadata, $metadata);
                     }
                 }
             }
             $cache->set($cacheId, self::$system_metadata);
         }
     }
     return self::$system_metadata;
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:40,代码来源:spatial_ref.php

示例9: delete

 /**
  * Delete a named variable value.
  * @param string $name Name of the variable to delete.
  */
 public static function delete($name)
 {
     $db = new Database();
     $db->delete('variables', array('name' => $name));
     $cache = Cache::instance();
     $cache->delete("variable-{$name}");
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:11,代码来源:variable.php

示例10: _clear_cache

 protected function _clear_cache()
 {
     if (Kohana::$caching === TRUE) {
         Cache::instance()->delete('Database::cache(' . Plugin::CACHE_KEY . '::plugin::' . $this->id() . ')');
     }
     return parent::_clear_cache();
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:database.php

示例11: clear_all

 public static function clear_all()
 {
     Cache::instance()->delete_all();
     Cache::clear_file();
     Cache::clear_routes();
     Cache::clear_profiler();
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:cache.php

示例12: get_new

 /**
  * Returns new users
  *
  * @param	int|string	$limit week, 50
  */
 public static function get_new($max = 'week')
 {
     $where = '';
     $limit = '';
     switch ($max) {
         case 'week':
             $where = " WHERE registered > CURRENT_DATE - INTERVAL '1 week' ";
             break;
         default:
             if (is_numeric($max)) {
                 $limit = ' LIMIT ' . $max;
             } else {
                 throw new Kohana_Exception('member.error_invalid_type');
             }
     }
     $cache = Cache::instance();
     $key = $cache->key('users', $max);
     $users = $cache->get($key);
     if (empty($users)) {
         $users = array();
         if ($result = Database::instance()->query("SELECT id, username, registered, DATE_TRUNC('day', registered) AS day FROM users " . $where . ' ORDER BY id DESC ' . $limit)) {
             foreach ($result as $user) {
                 $users[$user->day][] = $user;
             }
             $cache->set($key, $users, null, 3600);
         }
     }
     return $users;
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:34,代码来源:Users.php

示例13: action_index

 /**
  * @return	void
  */
 public function action_index()
 {
     $this->template->header->title = $this->bucket->bucket_name . ' ~ ' . __('Display Settings');
     $this->active = 'display';
     $this->settings_content = View::factory('pages/bucket/settings/display');
     $this->settings_content->bucket = $this->bucket;
     $session = Session::instance();
     if ($this->request->method() == "POST") {
         try {
             $this->bucket->bucket_name = $this->request->post('bucket_name');
             $this->bucket->bucket_publish = $this->request->post('bucket_publish');
             $this->bucket->default_layout = $this->request->post('default_layout');
             $this->bucket->save();
             // Force refresh of cached buckets
             Cache::instance()->delete('user_buckets_' . $this->user->id);
             // Redirect to the new URL with a success messsage
             $session->set("messages", array(__("Display settings were saved successfully.")));
             $this->request->redirect($this->bucket->get_base_url($this->bucket) . '/settings/display');
         } catch (ORM_Validation_Exception $e) {
             $this->settings_content->errors = $e->errors('validation');
         } catch (Database_Exception $e) {
             $this->settings_content->errors = array(__("A bucket with the name ':name' name already exists", array(":name" => $this->request->post('bucket_name'))));
         }
     }
     // Check for messages
     $this->settings_content->messages = $session->get('messages');
     $session->delete('messages');
 }
开发者ID:rukku,项目名称:SwiftRiver,代码行数:31,代码来源:display.php

示例14: beforeInit

 public static function beforeInit()
 {
     $cache = Cache::instance('file');
     self::$cache = $cache;
     $cacheAPI = new Wi3TikoCacheAPI($cache, Request::instance());
     self::$tiko = new tikoCacheController($cacheAPI);
 }
开发者ID:azuya,项目名称:Wi3,代码行数:7,代码来源:wi3tikocache.php

示例15: article

 public function article($uri)
 {
     $this->template->content = View::factory('blog/view')->bind('post', $post)->bind('comments', $comments)->bind('form', $form);
     $post = ORM::factory('blog_post', (string) $uri);
     // Show 404 if we don't find posts
     if (!$post->loaded) {
         Event::run('system.404');
     }
     $comments = $post->blog_comments;
     $this->head->title->prepend($post->title);
     if (!($post->comment_status === 'open' and config::get('blog.comment_status') === 'open')) {
         return;
     }
     $form = Formo::factory()->plugin('csrf')->add('text', 'author', array('label' => __('Name')))->add('text', 'email', array('label' => __('Email')))->add('text', 'url', array('label' => __('Homepage')))->add('textarea', 'content', array('label' => __('Comment')))->add('submit', 'submit', array('label' => __('Submit')))->pre_filter('all', 'trim')->pre_filter('author', 'security::xss_clean')->pre_filter('content', 'security::xss_clean')->pre_filter('url', 'security::xss_clean')->pre_filter('url', 'format::url')->add_rule('author', 'required', __('You must provide your name'))->add_rule('author', 'length[2,40]', __('Your Name is too long'))->add_rule('email', 'valid::email', __('Email address is not valid'))->add_rule('content', 'required', __('You must enter a comment'));
     if (config::get('blog.enable_captcha') === 'yes') {
         $form->add('captcha', 'security', array('label' => __('Security code')));
         $form->security->error_msg = __('Invalid security code');
     }
     if ($form->validate()) {
         $comment = ORM::factory('blog_comment');
         $comment->author = $form->author->value;
         $comment->email = $form->email->value;
         $comment->content = $form->content->value;
         $comment->url = $form->url->value;
         $comment->ip = $this->input->ip_address();
         $comment->agent = Kohana::$user_agent;
         $comment->date = date("Y-m-d H:i:s", time());
         $post->add_comment($comment);
         Event::run('blog.comment_added', $comment);
         Cache::instance()->delete('s7n_blog_feed');
         Cache::instance()->delete('s7n_blog_feed_comments');
         url::redirect($post->url());
     }
     $form = View::factory('blog/form_comment', $form->get(TRUE));
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:35,代码来源:blog.php


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