19 package org.sleuthkit.autopsy.discovery.search;
21 import com.google.common.cache.CacheBuilder;
22 import com.google.common.cache.LoadingCache;
23 import java.util.List;
25 import java.util.concurrent.ExecutionException;
36 class DomainSearchCache {
38 private static final int MAXIMUM_CACHE_SIZE = 10;
39 private static final LoadingCache<SearchKey, Map<GroupKey, List<Result>>> cache
40 = CacheBuilder.newBuilder()
41 .maximumSize(MAXIMUM_CACHE_SIZE)
42 .build(
new DomainSearchCacheLoader());
63 Map<GroupKey, List<Result>>
get(String userName,
64 List<AbstractFilter> filters,
65 DiscoveryAttributes.AttributeType groupAttributeType,
66 Group.GroupSortingAlgorithm groupSortingType,
67 ResultsSorter.SortingMethod domainSortingMethod,
68 SleuthkitCase caseDb, CentralRepository centralRepoDb)
throws DiscoveryException {
70 final SearchKey searchKey =
new SearchKey(userName, filters, groupAttributeType,
71 groupSortingType, domainSortingMethod, caseDb, centralRepoDb);
72 return cache.get(searchKey);
73 }
catch (ExecutionException ex) {
74 throw new DiscoveryException(
"Error fetching results from cache", ex.getCause());