id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blockedby,phpversion,appname,pending,exts,sapi,probability,blocking
112,better vardata caching by implementing pre-check/post-check algo,moo,moo," * Update API: xcache_isset($name [, $post_check_ttl])

Example usage:
{{{
#!php

<?php
define(TMPDIR, '/tmp');

function load_abc_data()
{
  $name = ""abc_data"";
  $ttl = 120; // cache for 2 minutes
  $post_check_ttl = 60; // reload every 1 minutes, while other reader keep using the stale data
  if (!xcache_isset($name, $post_check_ttl)) {
    // it worth a lock here to avoid useless yet harmful concurrent load from any slow backend (backend=mysql here).
    $fp = fopen(TMPDIR . ""/abc_data.lock"", ""w"");
    // only one worker update it and other keep on reading, if it's in post-check time
    $nb = xcache_isset($name) ? 0 : LOCK_NB;
    if (flock($fp, LOCK_EX | $nb)) {
      // check AGAIN after we get the lock
      if (!xcache_isset($name, $post_check_ttl)) {
        mysql_query .... and get $data
        xcache_set($name, $data, 120);
        fclose($fp);
        return $data;
      }
      else {
        fclose($fp);
      }
    }
  }
  return xcache_get($name);
}

?>

}}}



See [http://msdn2.microsoft.com/en-us/library/ms533020.aspx MSDN] for Cache-Control pre-check/post-check algo
",enhancement,new,major,4.0.0,cacher,2.0.0,,,,,,,0,,,,
