cosenary / Simple-PHP-Cache

A light, simple but powerful PHP5 Cache Class which uses the filesystem for caching.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I cache database results in a loop?

sharikul opened this issue · comments

Hi, I just came across this library today and I'm planning on implementing it on a project that I'm currently working on. The new project is essentially a new blogging app that retrieves and displays posts from the database, as you would expect. Problem is that it queries the database on every refresh even if there's no new data to be shown, which is why I want to go the caching route.

I've had a little play with this and I found that only the last data that's returned is cached, which is not what I want, so I literally have the last blog post displaying itself 6 times. I just want to ask: is there a way to cache data in a loop, properly?