I have to create an application in PHP which will store the phone contacts of different users.
The table for storing the phone numbers is of the following format:
id,user-id,phone-number
Whenever an user tries to view all his contacts, first of all the contents from the cache should be shown and then the remaining ones from the database.
In implementing this, I have the following problem:
How to store the phone numbers in the cache? By this I mean what should be the key for inserting the phone numbers into memcache so that I can easily extract the data from it for any user. Remember, each user can have many phone numbers and there are many users.
the key should use user id
suggestion value should be as simple as possible,
no JSON, no serialize data
this is to save spaces and also save processing for
json_decode / unserailizewhen getting all contacts for an user
when user adding/update/delete a mobile number,
or adding/update/delete a mobile number
your function should be if cache not exist in memcache,
fetch from database,
set memcache,
return the database result