cache lite / memcache
i have a function that build query depending on which page user i开发者_运维百科s at, by parameter array value, once it build the query, then it returns, so we can execute it and get the desire result we want.
well we need to put cache on it, so we can speed up things and im really confuse on how to make cache id, sence the query is kind of dynamic (depending on array value), which can also have search value too, which changes the result also, time to time, depend on what you are searching for.
my question is, is there anyway i can use the return query (select * from... .. ..) and make and id of it, maybe using md5 or some other way, which stay same if query is same and changes if query is different?
If you use the MD5 of the query, you will not be able to identify the key later in your memcache logs.
GET SQLCache:ad98234080acaffaac908233 isn't very good.
The best method is to name the key
Cache.set('catalog:books:1-200', books) and store blocks of "N" items per Cache.set page. This will enable you to build specific page blocks as needed.
Transversing a list isn't always the best way to handle a large amount of data.
You can pre-build your "lists" daily in a summary table, and then cache the results from there.
-daniel
精彩评论