Class AerospikeTemplate
java.lang.Object
org.springframework.data.aerospike.core.AerospikeTemplate
- All Implemented Interfaces:
AerospikeOperations
public class AerospikeTemplate extends Object implements AerospikeOperations
Primary implementation of
AerospikeOperations.- Author:
- Oliver Gierke, Peter Milne, Anastasiia Smirnova, Igor Ermolenko, Roman Terentiev
-
Constructor Summary
Constructors Constructor Description AerospikeTemplate(com.aerospike.client.IAerospikeClient client, String namespace, MappingAerospikeConverter converter, AerospikeMappingContext mappingContext, AerospikeExceptionTranslator exceptionTranslator, QueryEngine queryEngine, IndexRefresher indexRefresher) -
Method Summary
Modifier and Type Method Description <T> Tadd(T objectToAddTo, String binName, long value)<T> Tadd(T objectToAddTo, Map<String,Long> values)<T> Iterable<T>aggregate(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments)<T> Tappend(T objectToAppendTo, String binName, String value)<T> Tappend(T objectToAppendTo, Map<String,String> values)<T> longcount(Class<T> entityClass)Returns the amount of records in the given entityClass's Aerospike set and AerospikeTemplate configured namespace.<T> longcount(String setName)Returns the amount of records in the given Aerospike set and AerospikeTemplate configured namespace.<T> longcount(Query query, Class<T> entityClass)Returns the amount of records in a query results.<T> voidcreateIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType)Creates index by specified name in Aerospike.<T> voidcreateIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType)Creates index by specified name in Aerospike.<T> voiddelete(Class<T> entityClass)<T> booleandelete(Object id, Class<T> entityClass)<T> booleandelete(T objectToDelete)<T> voiddeleteIndex(Class<T> entityClass, String indexName)Deletes index by specified name from Aerospike.<T> Texecute(Supplier<T> supplier)Execute operation against underlying store.<T> booleanexists(Object id, Class<T> entityClass)<T> booleanexists(Query query, Class<T> entityClass)<T> Stream<T>find(Query query, Class<T> entityClass)<T> Stream<T>findAll(Class<T> entityClass)<T> Iterable<T>findAll(Sort sort, Class<T> entityClass)<T> TfindById(Object id, Class<T> entityClass)<T> List<T>findByIds(Iterable<?> ids, Class<T> entityClass)GroupedEntitiesfindByIds(GroupedKeys groupedKeys)Executes a single batch request to get results for several entities.<T> Stream<T>findInRange(long offset, long limit, Sort sort, Class<T> entityClass)com.aerospike.client.IAerospikeClientgetAerospikeClient()MappingContext<?,?>getMappingContext()StringgetNamespace()<T> StringgetSetName(Class<T> entityClass)booleanindexExists(String indexName)Checks whether index by specified name exists in Aerospike.<T> voidinsert(T document)Insert operation usingRecordExistsAction.CREATE_ONLYpolicy.<T> voidinsertAll(Collection<? extends T> documents)<T> voidpersist(T document, com.aerospike.client.policy.WritePolicy policy)Persist document using specified WritePolicy.<T> Tprepend(T objectToPrependTo, String fieldName, String value)<T> Tprepend(T objectToPrependTo, Map<String,String> values)<T> voidsave(T document)Save operation.<T> voidupdate(T document)Update operation usingRecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document if it is present.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.aerospike.core.AerospikeOperations
getMappingContext, getSetName
-
Constructor Details
-
AerospikeTemplate
public AerospikeTemplate(com.aerospike.client.IAerospikeClient client, String namespace, MappingAerospikeConverter converter, AerospikeMappingContext mappingContext, AerospikeExceptionTranslator exceptionTranslator, QueryEngine queryEngine, IndexRefresher indexRefresher)
-
-
Method Details
-
createIndex
public <T> void createIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType)Description copied from interface:AerospikeOperationsCreates index by specified name in Aerospike.- Specified by:
createIndexin interfaceAerospikeOperations
-
createIndex
public <T> void createIndex(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType, com.aerospike.client.query.IndexCollectionType indexCollectionType)Description copied from interface:AerospikeOperationsCreates index by specified name in Aerospike.- Specified by:
createIndexin interfaceAerospikeOperations
-
deleteIndex
Description copied from interface:AerospikeOperationsDeletes index by specified name from Aerospike.- Specified by:
deleteIndexin interfaceAerospikeOperations
-
indexExists
Description copied from interface:AerospikeOperationsChecks whether index by specified name exists in Aerospike.- Specified by:
indexExistsin interfaceAerospikeOperations- Parameters:
indexName- The Aerospike index name- Returns:
- true if exists
-
save
public <T> void save(T document)Description copied from interface:AerospikeOperationsSave operation. If document has version property - CAS algorithm is used for updating record. Version property is used for deciding whether to create new record or update existing. If version is set to zero - new record will be created, creation will fail is such record already exists. If version is greater than zero - existing record will be updated withRecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document. Version property will be updated with the server's version after successful operation. If document does not have version property - record is updated withRecordExistsAction.REPLACEpolicy. This means that when such record does not exist it will be created, otherwise updated.- Specified by:
savein interfaceAerospikeOperations- Parameters:
document- The document to save.
-
persist
public <T> void persist(T document, com.aerospike.client.policy.WritePolicy policy)Description copied from interface:AerospikeOperationsPersist document using specified WritePolicy.- Specified by:
persistin interfaceAerospikeOperations- Parameters:
document- The document to persist.policy- The Aerospike write policy for the inner Aerospike put operation.
-
insertAll
-
insert
public <T> void insert(T document)Description copied from interface:AerospikeOperationsInsert operation usingRecordExistsAction.CREATE_ONLYpolicy. If document has version property it will be updated with the server's version after successful operation.- Specified by:
insertin interfaceAerospikeOperations- Parameters:
document- The document to insert.
-
update
public <T> void update(T document)Description copied from interface:AerospikeOperationsUpdate operation usingRecordExistsAction.REPLACE_ONLYpolicy taking into consideration the version property of the document if it is present. If document has version property it will be updated with the server's version after successful operation.- Specified by:
updatein interfaceAerospikeOperations- Parameters:
document- The object to update.
-
delete
- Specified by:
deletein interfaceAerospikeOperations
-
delete
- Specified by:
deletein interfaceAerospikeOperations
-
delete
public <T> boolean delete(T objectToDelete)- Specified by:
deletein interfaceAerospikeOperations
-
exists
- Specified by:
existsin interfaceAerospikeOperations
-
findAll
- Specified by:
findAllin interfaceAerospikeOperations
-
findById
- Specified by:
findByIdin interfaceAerospikeOperations
-
findByIds
- Specified by:
findByIdsin interfaceAerospikeOperations
-
findByIds
Executes a single batch request to get results for several entities. Aerospike provides functionality to get records from different sets in 1 batch request. The methods allows to put grouped keys by entity type as parameter and get result as spring data aerospike entities grouped by entity type.- Specified by:
findByIdsin interfaceAerospikeOperations- Parameters:
groupedKeys- will never be null.- Returns:
- GroupedEntities grouped entities
-
aggregate
public <T> Iterable<T> aggregate(com.aerospike.client.query.Filter filter, Class<T> entityClass, String module, String function, List<com.aerospike.client.Value> arguments)- Specified by:
aggregatein interfaceAerospikeOperations
-
findAll
- Specified by:
findAllin interfaceAerospikeOperations
-
exists
-
execute
Description copied from interface:AerospikeOperationsExecute operation against underlying store.- Specified by:
executein interfaceAerospikeOperations- Parameters:
supplier- must not be null.- Returns:
- Execution result.
-
count
Description copied from interface:AerospikeOperationsReturns the amount of records in a query results.- Specified by:
countin interfaceAerospikeOperations- Parameters:
query- The query that provides the result set for count.entityClass- The class to provide for the query.- Returns:
- amount of records that the given query and entity class provided.
-
find
- Specified by:
findin interfaceAerospikeOperations
-
findInRange
- Specified by:
findInRangein interfaceAerospikeOperations
-
count
Description copied from interface:AerospikeOperationsReturns the amount of records in the given entityClass's Aerospike set and AerospikeTemplate configured namespace.- Specified by:
countin interfaceAerospikeOperations- Parameters:
entityClass- The class to extract the Aerospike set from.- Returns:
- amount of records in the set (in the configured namespace).
-
getAerospikeClient
public com.aerospike.client.IAerospikeClient getAerospikeClient()- Specified by:
getAerospikeClientin interfaceAerospikeOperations
-
count
Description copied from interface:AerospikeOperationsReturns the amount of records in the given Aerospike set and AerospikeTemplate configured namespace.- Specified by:
countin interfaceAerospikeOperations- Returns:
- amount of records in the set (in the configured namespace).
-
prepend
- Specified by:
prependin interfaceAerospikeOperations
-
prepend
- Specified by:
prependin interfaceAerospikeOperations
-
append
- Specified by:
appendin interfaceAerospikeOperations
-
append
- Specified by:
appendin interfaceAerospikeOperations
-
add
- Specified by:
addin interfaceAerospikeOperations
-
add
- Specified by:
addin interfaceAerospikeOperations
-
getSetName
-
getMappingContext
-
getNamespace
-