Ticket #30 (new enhancement)
xcache_get_for_update/xcache_lock/xcache_unlock (was Integrated locking system)
| Reported by: | Martyo | Owned by: | moo |
|---|---|---|---|
| Priority: | trivial | Milestone: | 2.0.0 |
| Component: | cacher | Version: | 1.2-dev |
| Keywords: | Cc: | ||
| Blocked By: | PHP Version: | ||
| Application: | Need User Feedback: | no | |
| Other Exts: | SAPI: | ||
| Probability: | Blocking: |
Description
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)
Change History
Note: See
TracTickets for help on using
tickets.

