Search code examples
memcachedmemcache-stats

Cannot access item in memcached which i'm adding from 2 seperate scripts


ok, so if i add object from one script i cannot access it from the other and vice versa. which is strange.

if i do the dump using memcached-tool and i get something like this ... which is ok both of the object are inside (candidate_2 and candidate_1 both are part of the public_group group).

add 1:public_group:candidate_2 0 1315556543 11 add :public_group:candidate_1 0 1315556543 13

I guess the problem is that one element has that "1" infront of the group definition. What is that i tried googlin' and nothing. Does anyone has any idea ?

thnx

ps: // using php & default memcache client script


Solution

  • I think you have to show us the code. The 1: in the first key (1:public_...) is a different key, I suspect that the code you are using isn't generating identical keys.

    You may want to create a function for your object like this

    public function generate_memcache_key() {
        $key = $this->id . ':public_group:candidate_:' . $this->candidate_id;
        return $key;
    }
    

    By incorporating the key generation into your object, you'll run less risk of having on-the-fly mis-creation of key ids.