All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zulia.server.search.QueryResultCache Maven / Gradle / Ivy

There is a newer version: 1.6.4
Show newest version
package io.zulia.server.search;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import io.zulia.message.ZuliaQuery.ShardQueryResponse;

public class QueryResultCache {
	private Cache queryResultCache;

	public QueryResultCache(int maxSize, int concurrency) {
		queryResultCache = CacheBuilder.newBuilder().concurrencyLevel(concurrency).maximumSize(maxSize).build();
	}

	public ShardQueryResponse getCachedShardQueryResponse(QueryCacheKey queryCacheKey) {
		return queryResultCache.getIfPresent(queryCacheKey);
	}

	public void storeInCache(QueryCacheKey queryCacheKey, ShardQueryResponse shardQueryResponse) {
		queryResultCache.put(queryCacheKey, shardQueryResponse);
	}

	public void clear() {
		queryResultCache.invalidateAll();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy