I am wondering if it is viable to store cached items in Session variables, rather than creating a file-based caching solution? Because it is once per user, it could reduce some extra calls to the database if a user visits more than one page. But is it worth the effort?
Share
If the data you are caching (willing to cache) does not depend on the user, why would you store in the session… which is attached to a user ?
Considering sessions are generally stored in files, it will not optimise anything in comparaison of using files yourself.
And if you have 10 users on the site, you will have 10 times the same data in cache ? I do not think this is the best way to cache things 😉
For data that is the same fo all users, I would really go with another solution, be it file-based or not (even for data specific to one user, or a group of users, I would probably not store it in session — except if very small, maybe)
Some things you can look about :
PEAR::Cache_LiteZend_CacheAPC, for example)memcachedNext question is : what do you need to cache ? For how long ? but that’s another problem, and only you can answer that 😉