Package com.codingchili.core.storage
Interface AsyncStorage<Value extends Storable>
- All Known Implementing Classes:
ElasticMap
,HazelMap
,IndexedMap
,IndexedMapPersisted
,IndexedMapVolatile
,JsonMap
,MongoDBMap
,PrivateMap
,SharedMap
public interface AsyncStorage<Value extends Storable>
Reuses the AsyncMap interface from hazelcast.
Storages implementing this class are recommended to create an index for
attributes that are queried. It is highly recommended to create an index
for the ID field, which is used by all Storable
classes.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
removes all existing entries from the storage.default void
checks if an entry exists for the given keycontext()
Get the context for the storage.void
get an entry with the given key, if the key does not match a value fails with #ValueMissingException
void
set the entry identified by the given key to the given valuevoid
putIfAbsent(Value value, io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
set the entry if it does not already exists.query()
initialize the construction of a query.default QueryBuilder<Value>
Creates a new query on the specified attribute.void
Removes an entry by its key.void
returns the amount of entries in the storage.void
updates the value of the given key if a value already exists.void
Get all values contained within the storage as a stream.
-
Method Details
-
get
get an entry with the given key, if the key does not match a value fails with #ValueMissingException
- Parameters:
key
- a unique key identifying an entryhandler
- callback
-
contains
default void contains(String key, io.vertx.core.Handler<io.vertx.core.AsyncResult<Boolean>> handler)checks if an entry exists for the given key- Parameters:
key
- the key to check if sethandler
- callback
-
put
set the entry identified by the given key to the given value- Parameters:
value
- the value to be set for the given keyhandler
- callback
-
putIfAbsent
set the entry if it does not already exists. fails with #ValueAlreadyPresentException
if the key already has a value.- Parameters:
value
- the value to be set if the entry does not exist.handler
- callback
-
remove
Removes an entry by its key.- Parameters:
key
- identifies the entry to be removed.handler
- callback
-
update
updates the value of the given key if a value already exists.- Parameters:
value
- the new value of the entryhandler
- callback
-
values
Get all values contained within the storage as a stream. Not recommended to use on large maps.- Parameters:
handler
- callback
-
clear
removes all existing entries from the storage.- Parameters:
handler
- callback
-
size
returns the amount of entries in the storage.- Parameters:
handler
- callback
-
context
StorageContext<Value> context()Get the context for the storage.- Returns:
- a storage context.
-
addIndex
- Parameters:
field
- the path to the attribute to index, must include the array token in #CoreStrings.STORAGE_ARRAY
.
-
query
QueryBuilder<Value> query()initialize the construction of a query.- Returns:
- a builder String for constructing the query.
-
query
Creates a new query on the specified attribute.- Parameters:
attribute
- the attribute to query.- Returns:
- a new query builder.
-