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

com.aerospike.jdbc.schema.AerospikeSchemaCache Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
package com.aerospike.jdbc.schema;

import com.aerospike.jdbc.model.CatalogTableName;
import com.aerospike.jdbc.model.DataColumn;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;

import java.time.Duration;
import java.util.List;
import java.util.Optional;

public final class AerospikeSchemaCache
        implements OptionalCache> {

    private final Cache> store;

    public AerospikeSchemaCache(Duration ttl) {
        store = CacheBuilder.newBuilder().expireAfterWrite(ttl).build();
    }

    @Override
    public Optional> get(CatalogTableName catalogTableName) {
        return Optional.ofNullable(store.getIfPresent(catalogTableName));
    }

    @Override
    public void put(CatalogTableName catalogTableName, List columns) {
        store.put(catalogTableName, columns);
    }

    @Override
    public void clear() {
        store.invalidateAll();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy