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 ...
随机推荐
- 爬虫三之beautifulsoup
基本使用 from bs4 import BeautifulSoup soup = BeautifulSoup(html#,'lxml','xml','html5lib') soup.prettify ...
- linux 系统目录权限
小结: 目录的读.写.执行权限 1. 可读r:表示具有浏览目录 下面文件及子目录的权限 ls dir 1)如果没有x权限,则不能进到目录,既无法执行cd dir 2)如果没有x权限,ls列表时可以看到 ...
- 选择排序--python
def findSmallest(arr): smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] & ...
- linux中忘记mysql用户root密码解决方案
1.vim /etc/my.cnf[mysqld]skip-grant-tables ##追加此行,跳过权限表, 2.重启mysqlsystemctl restart mysqld 3.mysql 登 ...
- Python 入门之Python基础数据类型及其方法
Python 入门之Python基础数据类型 1. 整型:int 用于计算,用于比较 (在赋值的时候先执行等号右边的内容) 1.1 整数的加 a = 10 b = 20 print(a + b) 结果 ...
- HNUSTOJ-1258 Time
1258: Time 时间限制: 1 Sec 内存限制: 128 MB提交: 16 解决: 11[提交][状态][讨论版] 题目描述 Digital clock use 4 digits to e ...
- Node.js+koa2
const Koa = require('koa') const app = new Koa() const bodyParser = require('koa-bodyparser') app.us ...
- I - The Values You Can Make (背包求具体方案)
题目大意 给你n个数,让你用这n个数在组成k的情况下,找到所有的value,这些value也由这n个数组成,且这些value组合在一起能够组成k 解法 看到题目我的想法就是母函数= =不过wa了,后来 ...
- 卸载OpenIV
最近把 GTA5 卸载了,于是也想把用来修改 MOD 的 OpenIV 也卸载了. 结果在设置中,进行卸载的时候,弹出这个窗口 解决方案 1.首先打开 文件所在位置 2.右键,选择 属性,打开文件所在 ...
- 在webpack中配置.vue组件页面的解析
1. 运行`cnpm i vue -S`将vue安装为运行依赖: 2. 运行`cnpm i vue-loader vue-template-compiler -D`将解析转换vue的包安装为开发依赖: ...