trying to avoid precision problems with small time measures
This commit is contained in:
parent
aef709a453
commit
91d3bc66c8
@ -55,7 +55,7 @@ function GenericCache (cache_policy, cache_validator) {
|
||||
}
|
||||
|
||||
me.beforeTileRender = function(req, res, callback) {
|
||||
req.windshaft_start = new Date().getTime()/1000.0;
|
||||
req.windshaft_start = new Date().getTime();
|
||||
var key = cache_key(req);
|
||||
var tile = me.cache.get(key);
|
||||
if(tile) {
|
||||
@ -67,9 +67,9 @@ function GenericCache (cache_policy, cache_validator) {
|
||||
callback(null);
|
||||
} else {
|
||||
me.cache_hits++;
|
||||
var timestamp = new Date().getTime()/1000.0;
|
||||
var timestamp = new Date().getTime();
|
||||
var delta = timestamp - req.windshaft_start;
|
||||
tile.cache_time = delta;
|
||||
tile.cache_time = delta/1000.0;
|
||||
tile.hits++;
|
||||
res.header('X-Cache-hit', 'true');
|
||||
res.send(tile.tile, tile.headers, 200);
|
||||
@ -82,13 +82,13 @@ function GenericCache (cache_policy, cache_validator) {
|
||||
}
|
||||
|
||||
me.afterTileRender = function(req, res, tile, headers, callback) {
|
||||
var timestamp = new Date().getTime()/1000.0;
|
||||
var timestamp = new Date().getTime();
|
||||
var delta = timestamp - req.windshaft_start;
|
||||
me.cache.put(cache_key(req), {
|
||||
tile: tile,
|
||||
headers: headers,
|
||||
timestamp: timestamp,
|
||||
render_time: delta,
|
||||
render_time: delta/1000.0,
|
||||
hits: 0});
|
||||
update_items(me.cache.size || 0);
|
||||
callback(null, tile, headers);
|
||||
|
Loading…
Reference in New Issue
Block a user