com.aerospike.jdbc.util.DatabaseMetadataBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-jdbc Show documentation
Show all versions of aerospike-jdbc Show documentation
A JDBC driver for the Aerospike database
package com.aerospike.jdbc.util;
import com.aerospike.jdbc.AerospikeConnection;
import com.aerospike.jdbc.AerospikeDatabaseMetadata;
import com.aerospike.jdbc.model.DriverPolicy;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import java.sql.SQLException;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
public class DatabaseMetadataBuilder {
private final Cache metadataCache;
public DatabaseMetadataBuilder(DriverPolicy driverPolicy) {
metadataCache = CacheBuilder.newBuilder()
.expireAfterWrite(Duration.ofSeconds(driverPolicy.getMetadataCacheTtlSeconds()))
.build();
}
public AerospikeDatabaseMetadata build(String url, AerospikeConnection connection)
throws SQLException {
try {
return metadataCache.get(url, () -> new AerospikeDatabaseMetadata(url, connection));
} catch (ExecutionException e) {
throw new SQLException(e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy