Memcache returning incorrect items.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kalthar
Forum Newbie
Posts: 7
Joined: Fri Dec 11, 2009 2:28 pm

Memcache returning incorrect items.

Post by kalthar »

I am having serious problems with Memcache.

Whenever I request a cache from the server, it always returns the same one, regardless of which one I call, if I clear the server memcache and go to a different page, it returns the correct result, but then that result is cached (When it should be returning the results of already cached pages).

The method is used in exactly the same way on other parts of the site, and yet it works perfectly and as it should.

I cannot post source code as it is a closed source project, sorry.

Thanks in advance.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Memcache returning incorrect items.

Post by Weirdan »

Since you can't post the code it's quite hard to identify the problem right away. I'd suggest inspecting memcache network traffic to see if the key is really updated. Another pitfall could be that you use memcache_add() instead of memcache_set(). Also, reading the source of ZF's memcache adapter it seems some memcache/memcache extension versions incorrectly treated 'set' requests as 'add's - there's a workaround for this issue in ZF's source.
kalthar
Forum Newbie
Posts: 7
Joined: Fri Dec 11, 2009 2:28 pm

Re: Memcache returning incorrect items.

Post by kalthar »

Well, thanks for that advice, they were all using set.

However the problem one another dev had altered the framework we use so that it caches certain parts of the page, and it calls the cache before the function call...

Bit of a stupid addition but i've sorted out a workaround accordingly.

Thanks for the advice though.
Post Reply