need help while using mecahced keys

View: New views
1 Messages — Rating Filter:   Alert me  

need help while using mecahced keys

by mvnr_83 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I am newbie to memcached. Currently i am working on PHP and i installed memcached on my system. I tired and succeed while create cache using set and get methods.

But i am confusing while assigning keys. Here is my requirement.

1) If user1 comes and fetch results from a table, fetched results are stored in cache using some key(say 'countryinfo')

then user2 comes and wants to fetch the same result from the database. Then how do we know the cache is already existed with the name 'countryinfo'.

I don't want to give the key name as static. I want it to be dynamic , coz i am running hundrads of queries in my project. It much complicate to maintain static keys for each query.

2) I am fetching different data from the same table using different where conditions. for example

 SELECT * FROM tbl_users WHERE user_id = 40

SELECT username,gender FROM tbl_users WHERE user_id = 50
........
...........

In this case, How do i maintain cache

Thanks in advance