Jonesie
Jonesie

Reputation: 7285

enyim and memcached : NOT_STORED errors

We are using memcached 1.2.4 via enyim and are finding it difficult to get some objects to cache. If I watch the memcache console it just says 'NOT_STORED'.

I think we need to use [serializable] but that doesnt always work. I cant find any documentation or relevant google hits.

Any one here got any clues?

Thanks

Upvotes: 0

Views: 2984

Answers (3)

Chris
Chris

Reputation: 5073

I had this problem to...I was running something like:

var = CACHE.fetch("key_name",1.day,true) do
  ModelName.find_by_id(id)
end

So I was having active record find a record for me but I didn't know that memcached doesn't store nil values. What was happening was active record was returning nil because it couldn't find the record and therefore I was telling memcache to store a nil value. The fix was simply this:

var = CACHE.fetch("key_name",1.day,true) do
  ModelName.find_by_id(id) || ""
end

I use Ruby to code with. Hope this helps.

Upvotes: 0

Jonesie
Jonesie

Reputation: 7285

Thanks and sorry for the late reply.

The problem was two-fold. Using [Serializable] was not adequate for some objects so we have to implement ISerializable. We were also using ADD rather than SET.

From memory I couldn't find an upgrade for memcached and once we fixed the above it worked.

Cheers

Upvotes: 0

Dustin
Dustin

Reputation: 91050

Strongly recommend upgraded your version of memcached.

NOT_STORED means just that, your data was not stored. If you are using the add command to store data, this means that there's already data under that key. If you are using replace it means that there's not data under that key. You probably mea set.

Upvotes: 3

Related Questions