HuyPV
Saturday, December 22, 2012
$lockKey = $key . '##lock';
$getLock = memcache_add($obj, $lockKey, 1, false, 3000);
// TODO handle timeout
while (!$getLock) {
$getLock = memcache_add($obj, $lockKey, 1, false, 3000);
usleep(1);
}
if ($getLock) {
memcache_set($obj, $key, $refreshValue);
memcache_delete($obj, $lockKey);
return TRUE;
}
Title:
Implement lock with memcache
Description:
$lockKey = $key . '##lock'; $getLock = memcache_add($obj, $lockKey, 1, false, 3000); // TODO handle timeout while (!$getLock) { ...
...
Rating:
4