File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -28,13 +28,20 @@ plugin.getProblem = function(problem, cb) {
28
28
const k = h . KEYS . problem ( problem ) ;
29
29
const _problem = cache . get ( k ) ;
30
30
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 {
33
41
log . debug ( 'cache hit: ' + k + '.json' ) ;
34
42
_ . extendOwn ( problem , _problem ) ;
35
43
return cb ( null , problem ) ;
36
44
}
37
- log . debug ( 'cache discarded for being no longer valid: ' + k + '.json' ) ;
38
45
}
39
46
40
47
plugin . next . getProblem ( problem , function ( e , _problem ) {
You can’t perform that action at this time.
0 commit comments