why does memcached not support “multi set”

拟墨画扇 提交于 2019-12-06 01:52:24

It's not supported in the text protocol because it'd be very, very complicated to express, no clients would support it, and it would provide very little that you can't already do from the text protocol.

It's supported in the binary protocol because it's a trivial use case of binary operations.

spymemcached supports it implicitly -- just do a bunch of sets and magic happens:

http://dustin.github.com/2009/09/23/spymemcached-optimizations.html

I don't know a lot about memcache internals, but I assume writes have to be blocking, atomic operations. I assume that allowing multiple set operations to be batched, you could block all reads for a long time (or risk a get occurring while only half of a write had been applied). Forcing writes to be done individually allows them to be interleaved fairly with gets.

I would imagine that the restriction against using multi sets is to avoid collisions when writing cached values to the memcache.

As an object cache, I can't foresee an example of when you would need transactional type writes. This use case seems less suited for a caching layer, but better suited for the underlying database.

If sets come in interleaved from different clients, it is most likely the case that for one key, the last one wins, or is at least close enough, until the cache is invalidated and a newer value is written.

As Gian mentions, there don't seem to be any good reasons to block reads from the cache while several or many writes to the cache happen.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!