// Create the document search cache and register a organisation master searcher
_documentSearchCache = new EHCachingSearchCache(name + "Organization", cacheManager, new EHCachingSearchCache.Searcher() {
@Override
public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
// Fetch search results from underlying master
OrganizationSearchResult result = ((OrganizationMaster) getUnderlying()).search((OrganizationSearchRequest)
EHCachingSearchCache.withPagingRequest(request, pagingRequest));
// Cache the result documents
EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());
// Return the list of result UniqueIds
return new ObjectsPair<>(result.getPaging().getTotalItems(),
EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
}
});
// Create the history search cache and register a organisation master searcher
_historySearchCache = new EHCachingSearchCache(name + "OrganizationHistory", cacheManager, new EHCachingSearchCache.Searcher() {
@Override
public ObjectsPair<Integer, List<UniqueId>> search(Bean request, PagingRequest pagingRequest) {
// Fetch search results from underlying master
OrganizationHistoryResult result = ((OrganizationMaster) getUnderlying()).history((OrganizationHistoryRequest)
EHCachingSearchCache.withPagingRequest(request, pagingRequest));
// Cache the result documents
EHCachingSearchCache.cacheDocuments(result.getDocuments(), getUidToDocumentCache());
// Return the list of result UniqueIds
return new ObjectsPair<>(result.getPaging().getTotalItems(),
EHCachingSearchCache.extractUniqueIds(result.getDocuments()));
}
});
// Prime document search cache
OrganizationSearchRequest defaultSearch = new OrganizationSearchRequest();