public class CassandraBlobStore extends AbstractKeyValueStore<byte[]> implements BlobStore
BlobStore
that is backed by Cassandra.
This implementation persists values that implement Serializable
by using vanilla Java serialization.
This implementation persists key values in a specific table that will be created in a keyspace dictated by the
schema manager
.
This implementation does not initiate its own Cassandra session
and must be
provided with one via a session factory
.
Constructor and Description |
---|
CassandraBlobStore(CassandraSessionFactory sessionFactory,
CassandraSchemaManagerFactory cassandraSchemaManagerFactory) |
Modifier and Type | Method and Description |
---|---|
void |
delete(String key,
String context) |
CompletableFuture<Void> |
deleteAsync(String key,
String context) |
Map<String,byte[]> |
enumerateContext(String context) |
CompletableFuture<Map<String,byte[]>> |
enumerateContextAsync(String context) |
Optional<byte[]> |
get(String key,
String context) |
CompletableFuture<Optional<byte[]>> |
getAsync(String key,
String context) |
Optional<Optional<byte[]>> |
getIfStale(String key,
String context,
long timestamp) |
CompletableFuture<Optional<Optional<byte[]>>> |
getIfStaleAsync(String key,
String context,
long timestamp) |
OptionalLong |
getLastUpdated(String key,
String context) |
CompletableFuture<OptionalLong> |
getLastUpdatedAsync(String key,
String context) |
String |
getName() |
long |
put(String key,
byte[] value,
String context,
Integer ttlInSeconds)
Put a value with a suggested time-to-live after which the value should be expired and removed from the store.
|
CompletableFuture<Long> |
putAsync(String key,
byte[] value,
String context,
Integer ttlInSeconds)
Put a value with a suggested time-to-live after which the value should be expired and removed from the store.
|
CompletableFuture<Void> |
truncateContextAsync(String context)
Remove all records for a given context.
|
put, putAsync, truncateContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
put, putAsync, truncateContext
public CassandraBlobStore(CassandraSessionFactory sessionFactory, CassandraSchemaManagerFactory cassandraSchemaManagerFactory) throws IOException
IOException
public long put(String key, byte[] value, String context, Integer ttlInSeconds)
KeyValueStore
Records are expired on a best effort basis and depending on the implementation it is possible to get an expired record.
put
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)ttlInSeconds
- the time to live in seconds for this key or no ttl if nullpublic Optional<byte[]> get(String key, String context)
get
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public CompletableFuture<Long> putAsync(String key, byte[] value, String context, Integer ttlInSeconds)
KeyValueStore
Records are expired on a best effort basis and depending on the implementation it is possible to get an expired record.
putAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)ttlInSeconds
- the time to live in seconds for this key or no ttl if nullpublic CompletableFuture<Optional<byte[]>> getAsync(String key, String context)
getAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public Optional<Optional<byte[]>> getIfStale(String key, String context, long timestamp)
getIfStale
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)timestamp
- the timestamp of the last known state such that if an record with a more recent timestamp is
found the provided timestamp will be considered stale and the new record will be returnedpublic OptionalLong getLastUpdated(String key, String context)
getLastUpdated
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public CompletableFuture<Optional<Optional<byte[]>>> getIfStaleAsync(String key, String context, long timestamp)
getIfStaleAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)timestamp
- the timestamp of the last known state such that if an record with a more recent timestamp is
found the provided timestamp will be considered stale and the new record will be returnedpublic CompletableFuture<OptionalLong> getLastUpdatedAsync(String key, String context)
getLastUpdatedAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public Map<String,byte[]> enumerateContext(String context)
enumerateContext
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public void delete(String key, String context)
delete
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public CompletableFuture<Map<String,byte[]>> enumerateContextAsync(String context)
enumerateContextAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public CompletableFuture<Void> deleteAsync(String key, String context)
deleteAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public CompletableFuture<Void> truncateContextAsync(String context)
KeyValueStore
truncateContextAsync
in interface KeyValueStore<byte[]>
context
- a context used to differentiate between keys with the same name (forms a compound key)public String getName()
getName
in interface KeyValueStore<byte[]>
Copyright © 2020. All rights reserved.