com.jaregu.database.queries.cache.QueriesMapCache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of queries Show documentation
Show all versions of queries Show documentation
Java based SQL templating project. Store your queries in *.sql files and build queries for execution. Supports simple expressions and conditional clauses and interface proxying for java-sql bridge.
package com.jaregu.database.queries.cache;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import com.jaregu.database.queries.QueryId;
import com.jaregu.database.queries.SourceId;
import com.jaregu.database.queries.compiling.PreparedQuery;
import com.jaregu.database.queries.parsing.ParsedQueries;
public class QueriesMapCache implements QueriesCache {
private ConcurrentHashMap sources = new ConcurrentHashMap<>();
private ConcurrentHashMap queries = new ConcurrentHashMap<>();
public QueriesMapCache() {
}
@Override
public ParsedQueries getParsedQueries(SourceId sourceId, Supplier queriesSupplier) {
return sources.computeIfAbsent(sourceId, (k) -> queriesSupplier.get());
}
@Override
public PreparedQuery getPreparedQuery(QueryId queryId, Supplier querySupplier) {
return queries.computeIfAbsent(queryId, (k) -> querySupplier.get());
}
}