Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Using Keyspace as a ThreadLocal

zznate edited this page Oct 20, 2010 · 1 revision

Thanks to user wolpert for the example (http://github.com/wolpert/)

private static final ThreadLocal <Keyspace> keyspaceHolder = new ThreadLocal <Keyspace> () {
	@Override protected Keyspace initialValue() {
		Cluster cluster = HFactory.getOrCreateCluster(clusterName, servers);
		return createKeyspace(keyspace, cluster);
	}
};

public static Keyspace getKeyspace() {
	return keyspaceHolder.get();
}
Clone this wiki locally