@@ -152,15 +152,18 @@ private AsyncLookup getAsyncLookup(
152
152
final FilterMap filterMap ,
153
153
final Function <String , Result <LmsAPITemplate >> lmsAPITemplateSupplier ) {
154
154
155
+ // check if there is already a lookup for the user in the cache, if not create one
155
156
if (!this .lookups .containsKey (userId )) {
156
157
this .createNewAsyncLookup (userId , filterMap , lmsAPITemplateSupplier );
157
158
}
158
-
159
+
160
+ // get the users lookup from the cache
159
161
final AsyncLookup asyncLookup = this .lookups .get (userId );
160
162
if (asyncLookup == null ) {
161
163
return null ;
162
164
}
163
165
166
+ // if the lookup still valid use it otherwise, create new empty one and use this
164
167
if (!asyncLookup .isValid (filterMap )) {
165
168
final AsyncLookup removed = this .lookups .remove (userId );
166
169
if (removed != null ) {
@@ -333,7 +336,9 @@ boolean isValid(final FilterMap filterMap) {
333
336
return false ;
334
337
}
335
338
336
- return this .lookupFilterCriteria .equals (filterMap );
339
+ boolean valid = this .lookupFilterCriteria .equals (filterMap );
340
+ System .out .println ("******************** valid: " + valid + " filterMap: " + filterMap );
341
+ return valid ;
337
342
}
338
343
339
344
boolean isRunning () {
@@ -342,17 +347,15 @@ boolean isRunning() {
342
347
}
343
348
final boolean running = this .asyncBuffers
344
349
.stream ()
345
- .filter (b -> !b .finished )
346
- .findFirst ()
347
- .isPresent ();
350
+ .anyMatch (b -> !b .finished );
348
351
if (!running ) {
349
352
this .timeCompleted = Utils .getMillisecondsNow ();
350
353
}
351
354
return running ;
352
355
}
353
356
354
357
void cancel () {
355
- this .asyncBuffers .stream (). forEach (AsyncQuizFetchBuffer ::cancel );
358
+ this .asyncBuffers .forEach (AsyncQuizFetchBuffer ::cancel );
356
359
}
357
360
}
358
361
0 commit comments