As for my experience, You should use multiple levels of cache. Implement both of Your solutions (provided that it's not the only code that uses SELECT title, body FROM posts WHERE id=%% If it is use only the first one).
As for my experience, You should use multiple levels of cache. Implement both of Your solutions (provided that it's not the only code that uses "SELECT title, body FROM posts WHERE id=%%". If it is use only the first one).
In the second version of code, You memcache. Get(query.hash()), but memcache. Put("feed_%s" % id, query_result).
This might not work as You want it to (unless You have an unusual version of hash() ;) ). I would avoid query.hash(). It's better to use something like posts-title-body-%id.
Try deleting a video when it's stored in cache as query.hash(). It can hang there for months as a zombie-video. By the way: id = GET_PARMS'id' query = query("SELECT title, body FROM posts WHERE id=%%", id) You take something from GET and put it right into the sql query?
That's bad (will result in SQL injection attacks).
Implement both" is a good point.. The code was Python-looking pseudo-code (which I made up for the question. If the code were real, obviously id would be validated and the query() function would properly escape the parameter) – dbr May 5 '09 at 20:14 1 Still, posting this might confuse newbies. Always better to add a sanitize(GET_PARAMS'id') or something.
Good question, btw. – Reef May 5 '09 at 21:34.
Depends on the usage pattern, but all things equal I'd vote for the first way because you'll only do the work of generating the feed 1 time.
It really depends on what your app does... The only way to answer this is to get some performance numbers from your existing app. Then you can find the code that takes the largest amount of time and work on improving that one.
As others have suggested here I'd profile your code and work out what is the slowest or most expensive part of the operation.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.