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

com.builtamont.cassandra.migration.internal.util.CachePrepareStatement Maven / Gradle / Ivy

package com.builtamont.cassandra.migration.internal.util;

import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;

import java.util.concurrent.ConcurrentHashMap;

public class CachePrepareStatement {
	private ConcurrentHashMap cacheStatement = new ConcurrentHashMap<>();

	private Session session;

	public CachePrepareStatement(Session session) {
		this.session = session;
	}

	public PreparedStatement prepare(String s){
		PreparedStatement ps = cacheStatement.get(s.hashCode());
		if(ps == null){
			ps = session.prepare(s);
			cacheStatement.put(s.hashCode(), ps);
		}
		return ps;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy