i’ve friendship_request database table , will if this table have say a million record
when i’ll try to search for requests concerning tom for example and actually there is no friendship request for tom in these million record so which is better:
to index to in memcache when some one send request to tom and then first try to check memcache for tom so if present go to database and make a search query.
OR to make a search query directly without first check memcache
which is faster?
thanks
i’ve friendship_request database table , will if this table have say a million record
Share
Checking against Memcache first will be faster. Like the name applies, items are stored in memory, and will have less I/O than a database look up. However, Memcached will evict any data if the server’s RAM becomes full. For this reason, it would be unwise to assume that any data put in Memcache will still be there. Even before the item’s time has expired.
Most Memcache wrappers and API’s will return FALSE, or NOT_FOUND. So your application will just need to identify if your requested items was stored, and if not, check the database. Upon completing the database search, simply record in Memcached the results or no results. This will prevent your application from re-running the same search again.
Here’s a quick interaction with Memcached
And a quick little PHP class example