note 84032 modified in function.memcache-set by danbrown

From: Date: Sat, 19 Jun 2010 03:57:42 +0000
Subject: note 84032 modified in function.memcache-set by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-170273@lists.php.net to get a copy of this message
Using set more than once for the same key seems to have unexpected results - it does not behave as a "replace," but instead seems to "set" more than one value for the same key. "get" may return any of the values. This was tested on a multiple-server setup - behaviour may be different if you only have one server. Remedy is to use a combination of replace and set: <?php $result = $memcache->replace( $key, $var ); if( $result == false ) { $result = $memcache->set( $key, $var ); } ?> --was-- Using set more than once for the same key seems to have unexpected results - it does not behave as a "replace," but instead seems to "set" more than one value for the same key. "get" may return any of the values. This was tested on a multiple-server setup - behaviour may be different if you only have one server. Remedy is to use a combination of replace and set: $result = $memcache->replace( $key, $var ); if( $result == false ) { $result = $memcache->set( $key, $var ); } http://php.net/manual/en/function.memcache-set.php

« previous php.notes (#170273) next »