I'd like to build a "feed" for recent activity related to a specific section of my site. I haven't used memcache before, but I'm thinking of something like this:
- When a new piece of information is submitted to the site, assign a unique key to it and also add it to memcache.
- Add this key to the end of an existing list in memcache, so it can later be referenced.
- When retrieving, first retrieve the list of keys from memcache
- For each key retrieved, retrieve the individual piece of information
- String the pieces together and return them as the "feed"
E.g., user comments: user writes, "Nice idea"
- Assign a unique key to "Nice idea," let's say key "1234"
- Insert a key/data pair into memcache, 1234 -> "Nice Idea"
- Append "1234" to an existing list of keys: key_list -> {2341,41234,124,341,1234}
- Now when retrieving, first query the key list: {2341,41234,124,341,1234}
- For each key in the key list, retrieve the data: 2341 -> "Yes" 41234 -> "Good point" 124 -> "That's funny" 341 -> "I don't agree" 1234 -> "Nice Idea"
Is this a good approach?
Thanks!