what happen with my memcache (and php), please help
Travis Boucher
tbone at nexopia.com
Fri Mar 9 03:04:45 UTC 2007
Try using add(). set() will set it unconditionally.
son at raider.co.nz wrote:
> Hello all
>
> I have a php page that call function bellow:
>
> ----------------------
>
> function redirect_process($key) {
> ....
> $value = $memcache->get($key); //get value from memcache
> if (!$value) {
> if (!$memcache->get('temp:'.$key)) {
> $memcache->set('temp:'.$key, 1); //set 1
> echo 'This key is NOT set';
> usleep(50000000); //sleep for 50 seconds
> $memcache->delete('temp:'.$key); //delete this key
> }
> else if ($memcache->get('temp:'.$key)) {
> echo 'this key AREADY set';
> }
> }
> }
>
> -------------------------------------
>
> Then I hit the page with a key that is not in memcache yet sing browsers
> (firefox) in my computer. The second is after the first.
>
> However, I never get the message "this key AREADY set".
>
> In both cases, I only get 'This key is NOT set'.
>
> I donot know why. I think that my code is very clear.
>
> Note: I ONLY "get this key AREADY set" message when I remove the code:
>
> usleep(50000000);
> $memcache->delete('temp:'.$key);
>
>
> Could you please help
> regards
> shoa
>
>
>
>
>
>
>
>
More information about the memcached
mailing list