Closed flyerhzm closed 11 years ago
I also add ext/libmemcached-0.32/m4/aclocal.m4, which is existed in the memcached gem, but not in master branch.
This is pretty ok but I don't want it to impact performance at all in the uncompressed case. So I think we should implement codec modules with encode/decode methods. If marshal=true (should change that variable name to encode), then the codec is called, otherwise the entire method dispatch is short-circuited like is currently the case.
Then turning on the codec still semantically allows for the possible that it doesn't actually encode, based on the flags, like you want.
Does that make sense?
This would be the biggest API change in the core class in 2 years. :-)
Fixed by #118
we want to compress/decompress data using zlib and change memcached flags to 1
current implementation makes it difficult to extend and make use of flags, so I extract encode/decode methods, and extend them in my rails project, like
def encode_with_compressed(value, marshal, flags) value = encode_without_compressed(value, marshal, flags) flags & (flags & FLAG_COMPRESSED) == 0 ? value : Zlib::Deflate.deflate(value) end alias_method_chain :encode, :compressed
def decode_with_compressed(value, marshal, flags) value = (flags & FLAG_COMPRESSED) == 0 ? value : Zlib::Inflate.inflate(value) decode_without_compressed(value, marshal, flags) end alias_method_chain :decode, :compressed