简体   繁体   English

Codeigniter缓存问题

[英]Codeigniter caching question

I'm fairly new to Codeigniter. 我对Codeigniter很陌生。 I have been reading the user guide extensively but one question has remained open for me. 我已经广泛阅读了用户指南,但是仍然有一个问题对我开放。

Consider this scenario: 考虑这种情况:

An article page, completely static with only one little dynamic text displaying the number of views this article has got. 文章页面,完全是静态的,只有一个小小的动态文本显示了本文获得的观看次数。

How could I cache such a page in order to serve it fast but still update the views counter? 我如何缓存这样的页面以便快速提供它,但仍更新视图计数器?

Any answer will be greatly appreciated, 任何答案将不胜感激,

Tom 汤姆

I'm pretty sure CI's caching out of the box is for full pages only, so your views count would not be updated. 我很确定CI的开箱即用缓存仅适用于整页,因此您的视图计数不会被更新。

You could either specify a large cache time eg $this->output->cache(180); 您可以指定较大的缓存时间,例如$this->output->cache(180); which would cache for 2 hours, and then update the count, or look in to partial caching. 它将缓存2个小时,然后更新计数,或查看部分缓存。 Here's one such library . 这是一个这样的图书馆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM