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 ...
随机推荐
- 多变量分析绘图(hue参数)以及盒图和小提琴图
1,函数stipplot() stipplot()函数用来画散点图,其x轴是离散型的变量 直接上代码 import seaborn as sns import numpy as np import p ...
- Go语言入门篇-Golang之文本编码处理
Golang之文本编码处理
- Python win32com模块 合并文件夹内多个docx文件为一个docx
Python win32com模块 合并文件夹内多个docx文件为一个docx #!/usr/bin/env python # -*- coding: utf-8 -*- from win32com. ...
- [LeetCode] 30. 串联所有单词的子串
题目链接: https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/ 题目描述: 给定一个字符串 s 和一 ...
- 小白学Python(20)—— Turtle 海龟绘图
Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴为y的坐标系原点,(0,0)位置开始,它根据一组函数指令的控制,在这个平面坐标系中移动,从而在它爬行 ...
- UESTC-1057 秋实大哥与花(线段树+成段加减+区间求和)
秋实大哥与花 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit St ...
- P3158 [CQOI2011]放棋子(dp+组合数)
P3158 [CQOI2011]放棋子 放棋子的顺序和方案数无关,所以可以从按颜色递推 设$f[u][p][k]$为放到第$u$种颜色,所剩空间$p*k$的方案数 $g[u][i][j]$表示第$u$ ...
- 【C#】获取"我的电脑"的名字,如This PC、这台计算机
原文:[C#]获取"我的电脑"的名字,如This PC.这台计算机 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接: ...
- Xdex(百度版)脱壳工具基本原理
[原创]Xdex(百度版)脱壳工具基本原理作 者: sherrydl时 间: 2015-12-13,10:52:45链 接: http://bbs.pediy.com/showthread.php?t ...
- luogu P1232 [NOI2013]树的计数
传送门 这题妙蛙 首先考虑构造出一个合法的树.先重新编号,把bfs序整成\(1,2,3...n\),然后bfs序就是按照从上到下从左往右的遍历顺序,所以可以考虑对bfs序分层,可以知道分层方式只会对应 ...