I'm using codeigniter to create a web app. I'm creating the drop down menus in the header. These are included on every page using load->view(). To populate the menus some quite complex SQL is used. The contents on the menu will change infrequently (once/twice a week), whereas the rest of the data on the page is constantly changing.
我正在使用codeigniter来创建一个Web应用程序。我正在标题中创建下拉菜单。这些都包含在每个页面上使用load-> view()。要填充菜单,需要使用一些非常复杂的SQL。菜单上的内容不经常更改(每周一次/两次),而页面上的其他数据不断变化。
Therefore I don't want the overhead of running this SQL everytime a page is loaded. I looked at using CI caching but its on a page level. I really only want to cache a small segment.
因此,我不希望每次加载页面时都运行此SQL的开销。我查看了使用CI缓存,但它在页面级别上。我真的只想缓存一小段。
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.
您认为最好的方法是什么?我想过把它写到文本文件中,但是你必须手动运行代码来经常写这个。
2 个解决方案
#1
5
Take a look at the query caching page, or alternatively you can use a caching library to cache sections of a page (preferred method IMHO) take a look at KhCache.
查看查询缓存页面,或者您也可以使用缓存库来缓存页面的部分(首选方法恕我直言),看看KhCache。
#2
2
Another good caching library I have found is from Phil Sturgeon. http://github.com/philsturgeon/codeigniter-cache
我找到的另一个好的缓存库来自Phil Sturgeon。 http://github.com/philsturgeon/codeigniter-cache
It allows caching models, libraries, or just partial caching like you describe.
它允许缓存模型,库或仅像您描述的部分缓存。
#1
5
Take a look at the query caching page, or alternatively you can use a caching library to cache sections of a page (preferred method IMHO) take a look at KhCache.
查看查询缓存页面,或者您也可以使用缓存库来缓存页面的部分(首选方法恕我直言),看看KhCache。
#2
2
Another good caching library I have found is from Phil Sturgeon. http://github.com/philsturgeon/codeigniter-cache
我找到的另一个好的缓存库来自Phil Sturgeon。 http://github.com/philsturgeon/codeigniter-cache
It allows caching models, libraries, or just partial caching like you describe.
它允许缓存模型,库或仅像您描述的部分缓存。