Kohana Cache
The default cache group is loaded based on the Cache::$default setting. It is set to the file driver as standard, however this can be changed within
the /application/boostrap.php file
// Change the default cache driver to memcache
Cache::$default = 'memcache'; // Load the memcache cache driver using default setting
$memcache = Cache::instance();
动态切换缓存方式为file
$key = 'AjSR/piQT24JaYEgh6V9tA==';
$data = array('id'=>1, 'name'=>'liuchao');
Cache::instance("file")->set($key, $data, 60);
print_r(Cache::instance("file")->get($key));
//Cache::instance("file")->set($key, $data, (CFG_DEBUG?-1:60));
E:\html\tproject\framebota\runtime\com.bota.work\cache\ac\aca9887487bd968425c04be6907f90152a54527d.cache
60
a:2:{s:2:"id";i:1;s:4:"name";s:7:"liuchao";}
kohana缓存实际应用及优化
E:\html\tproject\framebota\platform\bootstrap.php
if (class_exists('memcache')) {
Cache::$default = 'memcache'; // default is File set to Memcache
}
E:\html\tproject\framebota\platform\libraries\Uploader\General.php
line 52
$this->_url = ORM::factory('Platform', 8)->cached(3600)->get('p'.CFG_PLATE);
SELECT * FROM bota_platform WHERE id = 8;
可以优化为:
$urlpre = '';
$key = 'cache_cdns_url';
if(Cache::instance("file")->get($key)){
$urlpre = Cache::instance("file")->get($key);
}else{
$urlpre = BOTA::url('com.bota.cdns');
Cache::instance("file")->set($key, BOTA::url('com.bota.cdns'), 3600);
}
Kohana Cache的更多相关文章
- php 抽象类适配器设计模式
以Kohana Cache设计为例 1.抽象类:E:\html\tproject\framework\modules\cache\classes\Cache.php <?php defined( ...
- ubuntu 12.04下安装和配置kohana 3.3.3 的方法
一.先到官网下载3.3.3版本的压缩包到/var/www/1117/目录下(提前建好1117的目录)解压 解压好的文件有(applications\modules\system\build.xml\c ...
- kohana orm巧用字段备注支持扩展
1.SELECT * FROM `bota_language` WHERE `type` = 'order_type'; id key value type ---- ...
- Kohana Minion cli 学习
1.E:\html\tproject\framebota\platform\bootstrap.php Kohana::modules(array( 'auth' => MODPATH.'aut ...
- kohana学习经验
1.sql查询文件缓存使用 $tokens = DB::select('id', 'token') ->from('member') ->where('id', 'in', $users) ...
- php 后台转发和重定向的区别及kohana框架当前url加参数方式
1.重定向是浏览器行为,浏览器地址有变化:转发是后台服务器完成, url地址不变化. 2.kohana获取URL 当前url是http://soyoung.kohana.com/blog/add?id ...
- ASP.NET Core 折腾笔记二:自己写个完整的Cache缓存类来支持.NET Core
背景: 1:.NET Core 已经没System.Web,也木有了HttpRuntime.Cache,因此,该空间下Cache也木有了. 2:.NET Core 有新的Memory Cache提供, ...
- [Java 缓存] Java Cache之 DCache的简单应用.
前言 上次总结了下本地缓存Guava Cache的简单应用, 这次来继续说下项目中使用的DCache的简单使用. 这里分为几部分进行总结, 1)DCache介绍; 2)DCache配置及使用; 3)使 ...
- Spring cache简单使用guava cache
Spring cache简单使用 前言 spring有一套和各种缓存的集成方式.类似于sl4j,你可以选择log框架实现,也一样可以实现缓存实现,比如ehcache,guava cache. [TOC ...
随机推荐
- Spring Security Session Time Out
最近在用Spring Security做登录管理,登陆成功后,页面长时间无操作,超过session的有效期后,再次点击页面操作,页面无反应,需重新登录后才可正常使用系统. 为了优化用户体验,使得在se ...
- [BZOJ 3771] Triple(FFT+容斥原理+生成函数)
[BZOJ 3771] Triple(FFT+生成函数) 题面 给出 n个物品,价值为别为\(w_i\)且各不相同,现在可以取1个.2个或3个,问每种价值和有几种情况? 分析 这种计数问题容易想到生成 ...
- 数塔 Medium
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the ...
- read、readline 和 readlines 的区别?
假设a.txt的内容如下所示: 1 Hello 2 Welcome 3 What is the fuck... read:读取整个文件. read([size])方法从文件当前位置起读取size个字节 ...
- P3190 [HNOI2007]神奇游乐园
传送门 第一道插头 $dp$ 由于讲不清楚所以假装各位早就会插头 $dp$ 了 首先要的是一个闭合回路,所以可以用括号表示法表示状态,然后大力分类讨论 $1.$ 没有右插头和下插头 那么我们可以啥也不 ...
- python基础操作---list
#coding:utf-8 list1 = ['physics', 'chemistry', 1997, 2000]; list2 = [1, 2, 3, 4, 5 ]; list3 = [" ...
- Educational Codeforces Round 68 (Rated for Div. 2) C. From S To T (字符串处理)
C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...
- 长沙理工大学第十二届ACM大赛-重现赛I 主持人的烦恼 (sort)
链接:https://ac.nowcoder.com/acm/contest/1/I 来源:牛客网 主持人的烦恼 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 131072K,其他语 ...
- [易学易懂系列|golang语言|零基础|快速入门|(三)]
接下来,我们主要讲讲package. 先列举下go的package的一些核心特性: 1.go的package不局限于一个文件,组成一个package的多个文件,编译后实际上和一个文件类似,组成包的不同 ...
- python 文件夹下文件及文件夹名称获取
import os dirct = 'D:/data' dirList=[] fileList=[] files=os.listdir(dirct) #文件夹下所有目录的列表 print('files ...