I used to clear cash using flush() in PHP every day, like 5-10 times. I want to clear specific items cache to prevent caching all server cache. This is the right way:
Is it correct?
Yes, that is correct.
But be aware that Memcache::add() will fail if the key already exists. If you always want to write the data even though it exists already, you can use Memcache::set() instead.
Another a little bit funky thing with the memcache PHP class, is that TTL is measured in seconds, but if it is larger than 30 days it instead is interpreted as a date stamp (unix timestamp).