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);
}

 

最新文章

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

热门文章

  1. ftp搭建mysql服务器
  2. 【Linux开发】V4L2应用程序框架
  3. 1~n的全排列--阅文集团2018校招笔试题
  4. SwipeRefreshLayout和RecyclerView类
  5. Python 入门之Python简介
  6. Nginx 入门了解
  7. python学习五十五天subprocess模块的使用
  8. Windows 10 IoT Core Dashboard 无法安装的问题
  9. jQuery中$()可以有两个参数
  10. es5继承和es6类和继承