Cross-client memcached compatibility
tomash.brechko at gmail.com
Wed Jan 30 08:20:58 UTC 2008
On Wed, Jan 30, 2008 at 07:50:58 -0000, Kieran Benton wrote:
> How about standardising on something like json? Either that or
> we're basically going to have to put a custom serialization rules
> together each client has to follow?
I think there's simply no automatic solution to the problem. That's
because the problem itself is not how to get different clients agree
which flags to use, but how to get different platforms (programming
language included) to agree on how to interpret serialized data. For
instance, while we may agree that certain flag would mean the data is
a serialized map (i.e. the key/value container), not every language
has maps built-in (and some have more than one), thus the client will
fail to reconstruct the data structure automatically.
The solution to the whole problem is to have serialization hooks in
each client you use. Then you would simply agree how you serialize
your data across the clients you use (be it a custom format, or some
pre-existing), and implement the hooks for each client. This makes
sense even for a single client when you can implement less generic but
more efficient serialization for your needs.
So the remaining thing would be to agree which flag to use to signal
that the data is serialized. The answer is 0x1 ;).
On a side note, some clients encode the type of serialized data in
flags rather than data itself. I think this is something not to do,
- type info can alway be encoded in the data section itself.
- nested structures would call for such embedded encoding anyway.
- only when all information is in the data section you may call it
true serialization: the data is self contained and you may pass it
around (store to a file for instance), without the need to wrap it
in yet another format to store "type flags" along with it.
Such clients should be fixed then.
More information about the memcached