Skip to content

Commit

Permalink
previous commit to filecache was incomplete and broke some things cau…
Browse files Browse the repository at this point in the history
…ght in regression testing.
  • Loading branch information
bitsquare-www-data committed Nov 9, 2017
1 parent 734fbf3 commit 64a002e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/filecache.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,26 @@ static public function get( $file, $key, $value_cb, $value_cb_params=[] ) {
// So we use apcu for inter-request cache, and static var to cache during same request/process.
// todo: check if file has changed during same request/process. (lazy, eg after 2 secs)
// (checking mtime is slower and not really needed for use in a web app that is request oriented.)
static $results = null;
$statickey = $file . $key;
$val = @$results[$statickey];
static $results = [];
$fullkey = $file . $key;
$val = @$results[$fullkey];
if( $val ) {
return $val;
}

}
// in case apcu is not installed.
if( true || !function_exists( 'apcu_fetch' ) ) {
static $warned = false;
if( !$warned ) {
error_log( "Warning: APCu not found. Please install APCu extension for better performance." );
$warned = true;
}
$results[$key] = $val = call_user_func_array( $value_cb, $value_cb_params );
$results[$fullkey] = $val = call_user_func_array( $value_cb, $value_cb_params );
return $val;
}

$result_key = $key;
$ts_key = $file . $key . '_timestamp';
$result_key = $fullkey;
$ts_key = $fullkey . '_timestamp';

// We prefer to use apcu_entry if existing, because it is atomic.
// note: disabling this for now because the trades class get_by_market callback
Expand All @@ -62,7 +62,7 @@ static public function get( $file, $key, $value_cb, $value_cb_params=[] ) {
$result = apcu_entry( $result_key, function($key) use($file, $value_cb, $value_cb_params) {
return call_user_func_array( $value_cb, $value_cb_params );
});
$results[$key] = $result;
$results[$fullkey] = $result;
return $result;
}

Expand All @@ -78,7 +78,7 @@ static public function get( $file, $key, $value_cb, $value_cb_params=[] ) {
apcu_store( $ts_key, time() );
apcu_store( $result_key, $result );
}
$results[$key] = $result;
$results[$fullkey] = $result;
return $result;
}
}

0 comments on commit 64a002e

Please sign in to comment.