com.yandex.ydb.table.impl.QueryCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ydb-sdk-jdbc-uberjar Show documentation
Show all versions of ydb-sdk-jdbc-uberjar Show documentation
JDBC client implementation over Table client, single jar
package com.yandex.ydb.table.impl;
import javax.annotation.Nullable;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
/**
* @author Sergey Polovko
*/
final class QueryCache {
private final Cache cache;
QueryCache(int maxSize) {
this.cache = CacheBuilder.newBuilder()
.maximumSize(maxSize)
.build();
}
@Nullable
DataQueryImpl find(String text) {
String key = DataQueryImpl.makeHash(text);
return cache.getIfPresent(key);
}
void put(DataQueryImpl query) {
cache.put(query.getTextHash(), query);
}
void remove(DataQueryImpl query) {
cache.invalidate(query.getTextHash());
}
void clear() {
cache.asMap().clear();
}
}