Should i cache the whole query in php or should i just cache the primary key of the row?
The question is quite straightforward. I can't choose between either. In the dev documents MySQL has specified that indexes can pick a row from it's position rather than searching the whole table.
Suppost i have a 开发者_如何转开发request to fetch the 20 best posts in myPosts
table based on the ratings. Should i just cache the id
's of the retrieved Posts or Should i cache the whole results for responding further requests.
Btw i'm using file based caching.Memory is cheap and caching 20 rows usually don't take up much.
I would say: Cache the full rows if it isn't data that have a requirement to be fresh.
Rule of caching - cache data which has high probability of usage. In this case the probability is high so do cache them !
精彩评论