Could you imagine a solution for storing a set into memcached satisfying these requirements:
- must minimize round trips to the servers
O(1) add (for both current size and new items coming in)
O(1) remove (for both current size and items being removed)
- lock and wait free
- easy to use
- easy to understand
- no required explicit maintenance
Dustin Sallings describes how to achieve it using just three memcached operations and some clever but artificial data encoding.
Nuno Job suggests the right answer is using Redis.
Original title and link: How to Maintain a Set in Memcached (NoSQL databases © myNoSQL)