Skip to content

Commit

Permalink
feat: bypass_cache instead of bypass_read_cache
Browse files Browse the repository at this point in the history
Deprecates: option `bypass_read_cache`
With `bypass_cache` on, guanyu now ignores cache for lookup and update.
  • Loading branch information
clifflu committed Jul 19, 2016
1 parent 5df627d commit cb70319
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion guanyu/guanyu/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function get_result(payload) {
return Promise.resolve(payload);
}

if (payload.options && payload.options.bypass_read_cache) {
if (payload.options && payload.options.bypass_cache) {
logger.debug(`Skip cache lookup as requested "${payload.hash}"`);
return Promise.resolve(payload);
}
Expand Down Expand Up @@ -175,11 +175,17 @@ function update_result(payload) {
if (payload.cached) {
return Promise.resolve(payload);
}

if (!payload.hash) {
logger.error("Critical field `hash` missing on payload " + JSON.stringify(payload));
return Promise.reject("hash missing");
}

if (payload.options && payload.options.bypass_cache) {
logger.debug(`Skip updating cache as requested "${payload.hash}"`);
return Promise.resolve(payload);
}

let cached_entry = extend({}, payload, {cached: true});
delete cached_entry['options'];

Expand Down
2 changes: 1 addition & 1 deletion guanyu/guanyu/helper/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var extend = require('extend');

function collect_options(req) {
return {
bypass_read_cache: req.body.bypass_read_cache || false
bypass_cache: req.body.bypass_cache || req.body.bypass_read_cache || false
};
}

Expand Down
4 changes: 2 additions & 2 deletions guanyu/views/scan-file-usage.jade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ block content
dt (blob) file
dd File to scan

dt (bool) bypass_read_cache
dd Bypass read cache and force a re-scan.
dt (bool) bypass_cache
dd Bypass cache and force a re-scan.

h3 cURL

Expand Down
4 changes: 2 additions & 2 deletions guanyu/views/scan-text-usage.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ block content
dt (text) text
dd Text that guanyu will collect links from.

dt (bool) bypass_read_cache
dd Bypass read cache and force a re-scan.
dt (bool) bypass_cache
dd Bypass cache and force a re-scan.

h3 cURL

Expand Down
4 changes: 2 additions & 2 deletions guanyu/views/scan-uri-usage.jade
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ block content
dt (text) uri
dd Uri that Guanyu will download and scan.

dt (bool) bypass_read_cache
dd Bypass read cache and force a re-scan.
dt (bool) bypass_cache
dd Bypass cache and force a re-scan.

h3 cURL

Expand Down

0 comments on commit cb70319

Please sign in to comment.