Simple way to memcache (almost) all database queries
I’d probably argue that’s way too simple (and probably not so useful). What I’d do is:
make sure that I don’t have duplicates in the cache
Supporting this behavior is not so complex: a query cache will just store the keys of the results and use the multi_get for fetching these. In case objects are missing from the cache then you go on an execute the query making sure that this time you are caching each result object and the set of keys.
look into using a key-value store
This would definitely be more fun, not to mention that it might give you extremely good results. Take for example Redis, which is sometimes called memcached on steroids and check this benchmark results to get an idea of the performance.
via: http://bakery.cakephp.org/articles/view/simple-way-to-memcache-almost-all-database-queries