wndyd 发表于 2010-12-20 13:11:08

HEX的HMVC 如何做缓存?

群里没有人n我哦。只好自己发帖,求助了
昨天用了下Hex的HMVC.
按Hex说辞,可以把这个理解成一个控件
我现在要对这个控件进行缓存,要如何做呢?
我现在:
controller:
class news extends controller{
function details(){
....
$this->load->view('details_news');
}
}

views:
details_news.php
$this->load->module('caches/news/category');

modules:
class caches_news extends modules{
function category()
{
   $this->output->cache(30);
}
}
缓存的是 news details 并非我要的caches_news category

binbin 发表于 2010-12-20 16:56:15

本帖最后由 binbin 于 2010-12-20 17:01 编辑

缓存好像只能针对视图的输出进行缓存吧??
楼主可以使用数据库缓存类来实现你要的功能!

wndyd 发表于 2010-12-21 11:32:15

本帖最后由 wndyd 于 2010-12-21 11:33 编辑

我要缓存的就是视图,但是要缓存的是news_category.php这个视图,并不想要缓存news_detail.php这个视图,
本身news_detail.php这个视图调用了$this->load->module('caches/news/category');

class caches_news_module extends module{
...
function category()
{
    $this->cache->ouput(30);
    $this->load->view('news_category');
}
}

jeongee 发表于 2010-12-21 11:40:34

$this->cache->ouput(30);这个对hexHMVC无效的,你得自己想办法解决了

wndyd 发表于 2010-12-21 12:06:32

o 这样,之前我还指望他能给我带来局部片段缓存功能呢.谢谢了。

上善若水 发表于 2010-12-21 12:59:54

局部缓存和 hmvc 没关系,是ci的缓存类不成,你用三方的缓存类就可以了

我用MP_Cache,已经实现你的说的要求了。

Hex 发表于 2010-12-22 12:20:04

楼主的建议很好,可以考虑加入模块缓存功能!

上善若水 发表于 2010-12-22 13:08:23

本帖最后由 上善若水 于 2010-12-22 13:58 编辑

模块缓存 用MP_Cache+HEX的HMVC  可以实现,我已经在两个项目里用过了

tinsn 发表于 2012-3-17 17:30:03

Hex 发表于 2010-12-22 12:20 static/image/common/back.gif
楼主的建议很好,可以考虑加入模块缓存功能!

请问大大这个最新版本的HMVC里实现了吗?

Hex 发表于 2012-3-19 10:49:01

tinsn 发表于 2012-3-17 17:30 static/image/common/back.gif
请问大大这个最新版本的HMVC里实现了吗?

还没有模块缓存,呵呵
页: [1] 2
查看完整版本: HEX的HMVC 如何做缓存?