views:

32

answers:

1

Hello,

I use the memcache extension for python, and I have a very strange problem. Memcached refuses to store the exact same data with some keys, and succeeds in caching some others.

>>> import memcache
>>> conn = memcache.Client('121.0.0.1:11211', debug=0)
>>> conn.set('138b9c95d693760840aab85ee5591d2', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591d3', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d4', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591d5', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d6', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591d7', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d8', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591d9', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591e0', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591e1', 'test');
True

I don't really understand. I should add that I use the version 1.40 of the memcache module with memcached 1.2.8 running on Ubuntu Server 9.10. I restarted the memcached daemon, same result, with the same keys.

Thanks.

Update: I upgraded memcached to version 1.4.2, packaged on lucid repos, with the exact same result.

Update #2: The exact same commands entered on another server with a fresh ubuntu setup gives the same result, same places.

Update #3 As suggested, with a list instead of a string in the Client insantiation :

>>> import memcache
>>> conn = memcache.Client(['121.0.0.1:11211'], debug=0)
>>> conn.set('138b9c95d693760840aab85ee5591d2', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d3', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d4', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d5', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d6', 'test');
0
>>> conn.set('138b9c95d693760840aab85ee5591d7', 'test');
0
>>> 
>>> conn = memcache.Client('121.0.0.1:11211', debug=0)
>>> conn.set('138b9c95d693760840aab85ee5591d2', 'test');
True
>>> conn.set('138b9c95d693760840aab85ee5591d3', 'test');
0
+1  A: 

The first param should be a list

conn = memcache.Client(['127.0.0.1:11211'], debug=0)
gnibbler
Hum. Yep.But I'm afraid it's getting worse with a list, which I can't explain. I can't get it to work.See my update #3
Pierre
Are you sure your memcached is running? Try with `debug=1`
gnibbler
Hum... Yes, it is. But I feel pretty stupid now, as I typed 121 instead of 127 in the IP address...And it works now.Now, I don't understand why it did work...Thanks, by the way.
Pierre
@Pierre, Of course it never was working...just a weird bug in the memcache module I think
gnibbler