Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Only cache results that are not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkL4YG committed Nov 14, 2019
1 parent 1de21af commit 55c1f8b
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,13 @@ private List<IUser> computeIfNotCached(Predicate<IUser> matchBy, Supplier<List<I
}).orElseGet(() -> {
logger.trace("Computing result for search: {}", searchHint);
List<IUser> users = getBy.get();
CachedUserResult result =
new CachedUserResult(users, LocalDateTime.now().plusSeconds(USR_CACHE_TTL));
userCache.add(result);
return result.getUsers();
if (!users.isEmpty()) {
CachedUserResult result =
new CachedUserResult(users, LocalDateTime.now().plusSeconds(USR_CACHE_TTL));
userCache.add(result);
users = result.getUsers();
}
return users;
});
}
}
Expand Down

0 comments on commit 55c1f8b

Please sign in to comment.