mperham/dalli — Issue #157: dalli unexpectedly inserts extra characters
Author: elijahchancey
Created: 2012-01-09 23:07:47+00:00
State: open

Mike,

I'm really grateful for dalli. Thanks so much! I believe I've encountered a bug where Dalli inserts extra characters into a value when storing on memcache. Here are the steps to reproduce.

$ service memcached restart
Stopping memcached: [ OK ]
Starting memcached: [ OK ]

$ cat dalli_bug.rb
#!/usr/bin/ruby

require 'rubygems'
require 'dalli'

data = Hash.new
data["0000ebaf8d83785add834f97f3a81934"] = "ctx=4_240_h;ctx=4_272_m;ctx=2_463_m;ctx=2_464_l;ctx=2_23_l"

puts data.inspect

dalli_client = Dalli::Client.new("localhost:11211")
data.each do|key,value|
dalli_client.set(key, value)
end

$ ./dalli_bug.rb
{"0000ebaf8d83785add834f97f3a81934"=>"ctx=4_240_h;ctx=4_272_m;ctx=2_463_m;ctx=2_464_l;ctx=2_23_l"}

$ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
get 0000ebaf8d83785add834f97f3a81934
VALUE 0000ebaf8d83785add834f97f3a81934 1 62
"?ctx=4_240_h;ctx=4_272_m;ctx=2_463_m;ctx=2_464_l;ctx=2_23_l
END

So, it seems we have a "? that is appended at the beginning of the value. Am I doing something wrong or have I discovered a bug?

Thanks again,
Elijah