Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 791cdcf

Browse files
committed
Do not hit problem cache without full props
1 parent 4b4916d commit 791cdcf

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/plugins/cache.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,20 @@ plugin.getProblem = function(problem, cb) {
2828
const k = h.KEYS.problem(problem);
2929
const _problem = cache.get(k);
3030
if (_problem) {
31-
// Only hit description with html tags (<pre> always exists for presenting testcase)
32-
if (_problem.desc.includes("<pre>")) {
31+
// do not hit problem without html tags in desc (<pre> always exists for presenting testcase)
32+
if (!_problem.desc.includes("<pre>")) {
33+
log.debug('cache discarded for being no longer valid: ' + k + '.json');
34+
}
35+
// do not hit problem without likes & dislikes (logic will be improved in new lib)
36+
else if (!['likes', 'dislikes'].every(p => p in _problem)) {
37+
log.debug('cache discarded for being too old: ' + k + '.json');
38+
}
39+
// cache hit
40+
else {
3341
log.debug('cache hit: ' + k + '.json');
3442
_.extendOwn(problem, _problem);
3543
return cb(null, problem);
3644
}
37-
log.debug('cache discarded for being no longer valid: ' + k + '.json');
3845
}
3946

4047
plugin.next.getProblem(problem, function(e, _problem) {

0 commit comments

Comments
 (0)