Hi Yao,
Thanks for your reply.
I understand that the items (mc_item) are the actual unit for storing data. I've downloaded and studied the code. What I've ended up doing was create a list storing it sequentially in memory using the items. Storing the total length of the list in the nbyte field of the mc_item struct and the individual size of each element as a 4 byte value before each element. This gives the flexibility to store items of variable size. The structure looks something like this:
--------------------------------------------------------------------------------------------------------------------------------------------------
| item_1 size | item_1 payload | item_2 size | item_2 payload | ... | item_n size | item_n payload |
---------------------------------------------------------------------------------------------------------------------------------------------------
The way I store it in cache is somewhat similar to how the append functionality works. I calculate the new size of the list to see if its stille fit in the current slab or I have to move to another slab class. I haven't had much time to investigate the details of this and memory alignment. It was a quick solution that worked to see the inner workings of twemcache this weekend, but need to be polished.
I'm also still debating what could be an appropriate structure for a dictionary. I'm undecided between a balanced tree or storing a hash table at the beginning of the item.
I also modified a little bit a python client to insert values to the list, but I couldn't manage to retrive them from the cache (the connection closes and only sends an END marker. I have to check if this is an issue on the server side or the client side).
For the scripting support I see that redis has a nice interpreter of Lua built in. So I think its worth a shot to see how Redis did it.
I would love to get your thoughts on my strategy.
Thanks,
Mauricio