memcachex
memcachex copied to clipboard
Partial Dalli compatibility
This is enough to get Memcachex compatible with Dalli when they are both using a similar serializer (e.g. JSON). This only works if all they keys written by Dalli use the same serializer. In other words, if you write some keys with the JSON serializer and some raw with Dalli, then you can't read the raw keys from Memcachex using the JSON coder.
In more other words, Memcachex sets the serialization bit when writing, but it doesn't look for one when reading (it will always use a coder if present).
All test pass, but I'm not sure how to add tests for this since it requires Dalli reading keys that Memcachex sets.
The code is small, but pretty hacky, I don't really like it, sorry.
Addresses issue #7.
Sorry for taking too long to respond. I want to spend some time and figure out if there is any other way to support this without introducing hacks. But couldn't able to find much free time lately. Will try to spend some time on this issue soon.
Any chance of this or another solution making it's way in? I've just hit my head up against this issue too.
The chance of this getting merged in the current form is quite less. The problem is, I have built all the interfaces without ever exposing the flags field to the user.
The solution should be something like,
- figure out how to change
Memcache.Connectionso flag can be sent as input and be read back without breaking current api - then the same things should be done for
Memcachemodule.
There is also the question of whether Memcache.Coder should be able to receive & set the flag value.
Another approach is to change the dalli side to always compress by specifying suitable config. (compression_min_size as 0). Then you could write a custom coder that will always compress/decompress
defmodule Memcache.Coder.Dalli do
@behaviour Memcache.Coder
def encode(value, options), do: encode(value) |> zip
def decode(value, options), do: unzip(value) |> decode
end