I'm about to implement a memcached class which can be extended by our database class. However i have looked at many different ways of doing this.
My First question was, what is the point in the Memcached::set()
as it seems to replace the value of the key. Does this not defeat the object of caching your results?
My Second question was, technically speaking what is the fastest/best way to update the value of a key without checking the results every time the query is executed. If this happens, the results been retreived would have to be checked constantly so there would be no point in caching as the results would constantly be connecting to the mysql database.
Lastly, What is the best way of creating a key? most people recommend using MD5 however using MD5 on a PDO query would be the same regardless.
I.E.
$key = MD5("SELECT * FROM test WHERE category=?");
the category could produce many different results however the key would be constantly replaced. Is there a best practice for this?