﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	appname	phpversion	exts	sapi	probability	blockedby	blocking	pending
30	xcache_get_for_update/xcache_lock/xcache_unlock (was Integrated locking system)	Martyo	moo	"I would like x-cache to introduce an integrated locking system. Take for example this inefficient locking method:

{{{
while(xcache_get(""lock_test""))  { // check if lock exists
	usleep(10); // wait for 10ms
	$waittime += 10; // add wait time to variable
	if($waittime > 10000) { // check if we've been waiting for 10 seconds
		break;
	}
}
xcache_set(""lock_test"", true); // set the lock
$the_cache_test = xcache_get(""test""); // load the test cache into PHP
array_push($the_cache_test, ""a test""); // do some stuff here, change $the_cache_test
xcache_set(""test"", $the_cache_test);
xcache_set(""lock_test"", false); // unset the lock
}}}

Instead of this, I would suggest adding a locking value to xcache_get and xcache_set, like the following:

{{{
$new_method = xcache_get(""test"", true);
array_push($new_method, ""the new method"");
xcache_set(""test"", $new_method, false);
}}}

The ""true"" part in xcache_get sets the lock for ""test"". The ""false"" part in xcache_set sets the lock for ""test"" to false. If xcache_get is called and the lock is set, then xcache should sleep for 10ms and check again (this should be defined in the xcache PHP.ini settings)"	enhancement	new	trivial	4.0.0	cacher	1.2-dev											0
