arthurnn / memcached

A Ruby interface to the libmemcached C client
Academic Free License v3.0
432 stars 127 forks source link

:prefix_key ignored when :binary_protocol => true #35

Closed tarrall closed 13 years ago

tarrall commented 13 years ago

Setting the :prefix_key has no effect if you use binary_protocol:

c1 = Memcached.new("127.0.0.1",:prefix_key=>"test-ONE",:binary_protocol=>true)
c1.set "foo","bar"
=> nil
c1.get "foo"
=> "bar"
c2 = Memcached.new("127.0.0.1",:prefix_key=>"test-TWO",:binary_protocol=>true)
c2.get "foo"
=> "bar"

I believe the issue might be that libmemcached doesn't null-terminate the key for you: https://github.com/andreiz/php-memcached/commit/6abbe4b9f486224b4174764a4e7de15a73a6fa16

evan commented 13 years ago

Looks like it got fixed relatively recently in libmemcached: https://launchpad.net/libmemcached/+announcement/5548

evan commented 13 years ago

I got the basics working for an upgrade on branch '0.47', maybe you can take a stab at it?

evan commented 13 years ago

Hmm, benchmarks suggest that 0.47 is a performance regression. :-( I guess we should just patch it in place.

0.32:

set: libm:ascii                       0.610000   0.970000   1.580000 (  3.654520) 
set: libm:bin                         0.500000   0.890000   1.390000 (  3.118490)
get: libm:ascii                       0.820000   1.000000   1.820000 (  3.914436)

0.47:

set: libm:ascii                       0.670000   1.240000   1.910000 (  4.110841)
set: libm:bin                         0.570000   1.340000   1.910000 (  3.962299)
get: libm:ascii                       0.790000   1.240000   2.030000 (  4.129513)
evan commented 13 years ago

Fixed by hand in 1.2.