Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Dalli compatibility #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cjbottaro
Copy link
Contributor

@cjbottaro cjbottaro commented Jul 1, 2017

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.

@ananthakumaran
Copy link
Owner

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.

@aspett
Copy link

aspett commented Feb 27, 2019

Any chance of this or another solution making it's way in? I've just hit my head up against this issue too.

@ananthakumaran
Copy link
Owner

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,

  1. figure out how to change Memcache.Connection so flag can be sent as input and be read back without breaking current api
  2. then the same things should be done for Memcache module.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants