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

com.jaregu.database.queries.cache.QueriesMapCache Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.4.1
Show newest version
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());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy