[英]Caching one section of a CodeIgniter page
I'm using codeigniter to create a web app. 我正在使用codeigniter来创建一个Web应用程序。 I'm creating the drop down menus in the header.
我正在标题中创建下拉菜单。 These are included on every page using load->view().
这些都包含在每个页面上使用load-> view()。 To populate the menus some quite complex SQL is used.
要填充菜单,需要使用一些非常复杂的SQL。 The contents on the menu will change infrequently (once/twice a week), whereas the rest of the data on the page is constantly changing.
菜单上的内容不经常更改(每周一次/两次),而页面上的其他数据不断变化。
Therefore I don't want the overhead of running this SQL everytime a page is loaded. 因此,我不希望每次加载页面时都运行此SQL的开销。 I looked at using CI caching but its on a page level.
我查看了使用CI缓存,但它在页面级别上。 I really only want to cache a small segment.
我真的只想缓存一小段。
What do you think the best approach to this is? 您认为最好的方法是什么? I thought about writing this to a text file, but then you'd have to manually run the code to write this every so often.
我想把它写到一个文本文件中,但是你必须手动运行代码来经常写这个。
Another good caching library I have found is from Phil Sturgeon. 我找到的另一个好的缓存库来自Phil Sturgeon。 http://github.com/philsturgeon/codeigniter-cache
http://github.com/philsturgeon/codeigniter-cache
It allows caching models, libraries, or just partial caching like you describe. 它允许缓存模型,库或仅像您描述的部分缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.