In my website , i want to show some data which will be displayed from the db for the whole day .
For example, if i have a portion like ‘ Picture of the day’, then i will pick a random picture from the db and display them on the page.
So i dont want the query to be executed for every request . so i decided to use memcached to cache query results for a particular time(may be for 24 hrs) ..
All worked in localhost but my hosting provider does not have them.. So i have to use some different concepts to accomplish this.
Is there any equivalent for memcache in php?
You could use a file for caching, and a
filemtime()call to see whether the pick needs to be refereshed. Or a database record containing the pick, and the date it was made.Both methods would work fine performance-wise for this task – memcache sounds like a bit of overkill for it (although it’s obviously convenient to use when it’s available)