Memcached set() fails: WRITE FAILURE
Solution 1
I had the same problem today.
It turns out you need to use 127.0.0.1 instead of localhost.
Really annoying.
Solution 2
Sounds almost as if you're hitting the memory limit on Memcached. What kinds of things are you writing? How big are they?
If you Memcached server is full or almost full, I might even expect this to happen.
On the other hand, double check that you don't have a rate-limiting firewall installed. Perhaps it sees you banging away at your Memcached box and is freaking out.
Lastly, make sure that you're closing your Memcached connection when you're done with it. If you leave too many open, things get ugly.
jab11
Updated on June 04, 2022Comments
-
jab11 almost 2 years
So Memcached fails to write certain keys, getResultMessage() says
WRITE FAILURE
I'm using this in setup:$this->mmcache = new Memcached(); $this->mmcache->addServer('localhost',11211, 100); $this->mmcache->setOption(Memcached::OPT_BINARY_PROTOCOL, true); $this->mmcache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_IGBINARY); $this->mmcache->setOption(Memcached::OPT_COMPRESSION, false);
Some keys work every time, some fail everytime. I even tried base64 encoding the keys but they fail anyway, even simple function like
for($i=1;$i<100;$i++) { $this->mmcache->set('testkey'.$i,$i*100,600); }
returns
WRITE FAILURE
every time.Disabling the binary protocol just changes the error to
HOSTNAME LOOKUP FAILURE
but like 50% of keys still work and I just can't figure out which will and which won't work.Sorry I was asking wrong question before.
original question: Memcache in v1.4.4 returning NULL
I'm storing and reading large quantities of data in memcache from php. I'm using regular connect to memcache server which runs on localhost. I'm using Memcache 1.4.4But from 50-60 keys that I'm reading from memcache in one script run, more than 50% come back as
null
. According to php.net,Memcache::get()
should return false when key doesn't exist or expired. So why would it return "null" ?This happens even for keys that I just wrote to memcache. I cache something for 24 hours and in a minute I'm getting "null" instead. Memcache is not even 50% full so there's no reason for keys to be purged and even if they were, they should come back as false and not null.
Has anybody else encountered this problem ?
-
David Xia about 9 yearsThis worked for me. My php Memcached class used to work with "localhost". Was there a regression in a newer version?