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 Details

  • Method Details

    • createIndex

      public <T> void createIndex​(Class<T> entityClass, String indexName, String binName, com.aerospike.client.query.IndexType indexType)
      Description copied from interface: AerospikeOperations
      Creates index by specified name in Aerospike.
      Specified by:
      createIndex in interface AerospikeOperations
    • 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: AerospikeOperations
      Creates index by specified name in Aerospike.
      Specified by:
      createIndex in interface AerospikeOperations
    • deleteIndex

      public <T> void deleteIndex​(Class<T> entityClass, String indexName)
      Description copied from interface: AerospikeOperations
      Deletes index by specified name from Aerospike.
      Specified by:
      deleteIndex in interface AerospikeOperations
    • indexExists

      public boolean indexExists​(String indexName)
      Description copied from interface: AerospikeOperations
      Checks whether index by specified name exists in Aerospike.
      Specified by:
      indexExists in interface AerospikeOperations
      Parameters:
      indexName - The Aerospike index name
      Returns:
      true if exists
    • save

      public <T> void save​(T document)
      Description copied from interface: AerospikeOperations
      Save 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 with RecordExistsAction.REPLACE_ONLY policy 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 with RecordExistsAction.REPLACE policy. This means that when such record does not exist it will be created, otherwise updated.
      Specified by:
      save in interface AerospikeOperations
      Parameters:
      document - The document to save.
    • persist

      public <T> void persist​(T document, com.aerospike.client.policy.WritePolicy policy)
      Description copied from interface: AerospikeOperations
      Persist document using specified WritePolicy.
      Specified by:
      persist in interface AerospikeOperations
      Parameters:
      document - The document to persist.
      policy - The Aerospike write policy for the inner Aerospike put operation.
    • insertAll

      public <T> void insertAll​(Collection<? extends T> documents)
    • insert

      public <T> void insert​(T document)
      Description copied from interface: AerospikeOperations
      Insert operation using RecordExistsAction.CREATE_ONLY policy. If document has version property it will be updated with the server's version after successful operation.
      Specified by:
      insert in interface AerospikeOperations
      Parameters:
      document - The document to insert.
    • update

      public <T> void update​(T document)
      Description copied from interface: AerospikeOperations
      Update operation using RecordExistsAction.REPLACE_ONLY policy 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:
      update in interface AerospikeOperations
      Parameters:
      document - The object to update.
    • delete

      public <T> void delete​(Class<T> entityClass)
      Specified by:
      delete in interface AerospikeOperations
    • delete

      public <T> boolean delete​(Object id, Class<T> entityClass)
      Specified by:
      delete in interface AerospikeOperations
    • delete

      public <T> boolean delete​(T objectToDelete)
      Specified by:
      delete in interface AerospikeOperations
    • exists

      public <T> boolean exists​(Object id, Class<T> entityClass)
      Specified by:
      exists in interface AerospikeOperations
    • findAll

      public <T> Stream<T> findAll​(Class<T> entityClass)
      Specified by:
      findAll in interface AerospikeOperations
    • findById

      public <T> T findById​(Object id, Class<T> entityClass)
      Specified by:
      findById in interface AerospikeOperations
    • findByIds

      public <T> List<T> findByIds​(Iterable<?> ids, Class<T> entityClass)
      Specified by:
      findByIds in interface AerospikeOperations
    • findByIds

      public GroupedEntities findByIds​(GroupedKeys groupedKeys)
      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:
      findByIds in interface AerospikeOperations
      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:
      aggregate in interface AerospikeOperations
    • findAll

      public <T> Iterable<T> findAll​(Sort sort, Class<T> entityClass)
      Specified by:
      findAll in interface AerospikeOperations
    • exists

      public <T> boolean exists​(Query query, Class<T> entityClass)
    • execute

      public <T> T execute​(Supplier<T> supplier)
      Description copied from interface: AerospikeOperations
      Execute operation against underlying store.
      Specified by:
      execute in interface AerospikeOperations
      Parameters:
      supplier - must not be null.
      Returns:
      Execution result.
    • count

      public <T> long count​(Query query, Class<T> entityClass)
      Description copied from interface: AerospikeOperations
      Returns the amount of records in a query results.
      Specified by:
      count in interface AerospikeOperations
      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

      public <T> Stream<T> find​(Query query, Class<T> entityClass)
      Specified by:
      find in interface AerospikeOperations
    • findInRange

      public <T> Stream<T> findInRange​(long offset, long limit, Sort sort, Class<T> entityClass)
      Specified by:
      findInRange in interface AerospikeOperations
    • count

      public <T> long count​(Class<T> entityClass)
      Description copied from interface: AerospikeOperations
      Returns the amount of records in the given entityClass's Aerospike set and AerospikeTemplate configured namespace.
      Specified by:
      count in interface AerospikeOperations
      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:
      getAerospikeClient in interface AerospikeOperations
    • count

      public <T> long count​(String setName)
      Description copied from interface: AerospikeOperations
      Returns the amount of records in the given Aerospike set and AerospikeTemplate configured namespace.
      Specified by:
      count in interface AerospikeOperations
      Returns:
      amount of records in the set (in the configured namespace).
    • prepend

      public <T> T prepend​(T objectToPrependTo, String fieldName, String value)
      Specified by:
      prepend in interface AerospikeOperations
    • prepend

      public <T> T prepend​(T objectToPrependTo, Map<String,​String> values)
      Specified by:
      prepend in interface AerospikeOperations
    • append

      public <T> T append​(T objectToAppendTo, Map<String,​String> values)
      Specified by:
      append in interface AerospikeOperations
    • append

      public <T> T append​(T objectToAppendTo, String binName, String value)
      Specified by:
      append in interface AerospikeOperations
    • add

      public <T> T add​(T objectToAddTo, Map<String,​Long> values)
      Specified by:
      add in interface AerospikeOperations
    • add

      public <T> T add​(T objectToAddTo, String binName, long value)
      Specified by:
      add in interface AerospikeOperations
    • getSetName

      public <T> String getSetName​(Class<T> entityClass)
    • getMappingContext

      public MappingContext<?,​?> getMappingContext()
    • getNamespace

      public String getNamespace()