public class InMemoryStore extends Object implements KVStore
Constructor and Description |
---|
InMemoryStore() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
count(Class<?> type)
Returns the number of items of the given type currently in the store.
|
long |
count(Class<?> type,
String index,
Object indexedValue)
Returns the number of items of the given type which match the given indexed value.
|
void |
delete(Class<?> type,
Object naturalKey)
Removes an object and all data related to it, like index entries, from the store.
|
<T> T |
getMetadata(Class<T> klass)
Returns app-specific metadata from the store, or null if it's not currently set.
|
<T> T |
read(Class<T> klass,
Object naturalKey)
Read a specific instance of an object.
|
void |
setMetadata(Object value)
Writes the given value in the store metadata key.
|
<T> KVStoreView<T> |
view(Class<T> type)
Returns a configurable view for iterating over entities of the given type.
|
void |
write(Object value)
Writes the given object to the store, including indexed fields.
|
public <T> T getMetadata(Class<T> klass)
KVStore
The metadata type is application-specific. This is a convenience method so that applications don't need to define their own keys for this information.
getMetadata
in interface KVStore
public void setMetadata(Object value)
KVStore
setMetadata
in interface KVStore
public long count(Class<?> type)
KVStore
public long count(Class<?> type, String index, Object indexedValue) throws Exception
KVStore
public <T> T read(Class<T> klass, Object naturalKey)
KVStore
public void write(Object value) throws Exception
KVStore
Writes may be slower when the object already exists in the store, since it will involve updating existing indices.
public void delete(Class<?> type, Object naturalKey)
KVStore
public <T> KVStoreView<T> view(Class<T> type)
KVStore
public void close()
close
in interface java.io.Closeable
close
in interface AutoCloseable