Kohana Cache
2024-09-05 20:12:47
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);
}
最新文章
- 关于vector的内存释放问题
- Genymotion出现virtualbox cannot start the virtual device错误
- nodejs安装心得
- PHP表单处理
- 事件日志ID 2511:服务器服务无法重新创建 <;sharename>; 共享关系,因为 <;address>; 目录已不再存在
- JDBC(用Eclipse操作数据库Oracle)的基础操作集合
- sql的游标使用(转)
- sort函数使用的基本知识
- Java开发小技巧(二):自定义Maven依赖
- vue2 vue-rout
- viewpager 设置预加载项
- AspNetCore.FileLog 一款很不错的日志记录工具
- Qt 编程指南 1 从Hello World开始
- 微信小程序开发3之保存数据及页面跳转
- react中的路由模块化
- VirtualBox中CentOS遇到的问题
- MongoDB副本集配置系列三:副本集的认证方式
- FreeMarker标签使用
- c网络编程-多播
- 如何快速选中某单元格所在的整行或整列 Excel教程