java.lang.Object
software.amazon.lambda.powertools.idempotency.persistence.BasePersistenceStore
software.amazon.lambda.powertools.idempotency.persistence.dynamodb.DynamoDBPersistenceStore
All Implemented Interfaces:
org.crac.Resource, software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore

public final class DynamoDBPersistenceStore extends software.amazon.lambda.powertools.idempotency.persistence.BasePersistenceStore implements software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore, org.crac.Resource
DynamoDB version of the PersistenceStore. Will store idempotency data in DynamoDB.
Use the DynamoDBPersistenceStore.Builder to create a new instance.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Use this builder to get an instance of DynamoDBPersistenceStore.
    With this builder you can configure the characteristics of the DynamoDB Table (name, key, sort key, and other field names).
    You can also set a custom DynamoDbClient for further tuning.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class software.amazon.lambda.powertools.idempotency.persistence.BasePersistenceStore

    payloadValidationEnabled
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    afterRestore(org.crac.Context<? extends org.crac.Resource> context)
     
    void
    beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> context)
    Primes the persistent store by invoking the get record method with a key that doesn't exist.
     
    void
    deleteRecord(String idempotencyKey)
     
    software.amazon.lambda.powertools.idempotency.persistence.DataRecord
    getRecord(String idempotencyKey)
     
    void
    putRecord(software.amazon.lambda.powertools.idempotency.persistence.DataRecord record, Instant now)
    Store's the given idempotency record in the DDB store.
    void
    updateRecord(software.amazon.lambda.powertools.idempotency.persistence.DataRecord record)
     

    Methods inherited from class software.amazon.lambda.powertools.idempotency.persistence.BasePersistenceStore

    configure, deleteRecord, getRecord, saveInProgress, saveSuccess

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • beforeCheckpoint

      public void beforeCheckpoint(org.crac.Context<? extends org.crac.Resource> context) throws Exception
      Primes the persistent store by invoking the get record method with a key that doesn't exist.
      Specified by:
      beforeCheckpoint in interface org.crac.Resource
      Parameters:
      context -
      Throws:
      Exception
    • afterRestore

      public void afterRestore(org.crac.Context<? extends org.crac.Resource> context) throws Exception
      Specified by:
      afterRestore in interface org.crac.Resource
      Throws:
      Exception
    • builder

      public static DynamoDBPersistenceStore.Builder builder()
    • getRecord

      public software.amazon.lambda.powertools.idempotency.persistence.DataRecord getRecord(String idempotencyKey) throws software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemNotFoundException
      Specified by:
      getRecord in interface software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore
      Throws:
      software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemNotFoundException
    • putRecord

      public void putRecord(software.amazon.lambda.powertools.idempotency.persistence.DataRecord record, Instant now) throws software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemAlreadyExistsException
      Store's the given idempotency record in the DDB store. If there is an existing record that has expired - either due to the cache expiry or due to the in_progress_expiry - the record will be overwritten and the idempotent operation can continue. Note: This method writes only expiry and status information - not the results of the operation itself.
      Specified by:
      putRecord in interface software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore
      Parameters:
      record - DataRecord instance to store
      now -
      Throws:
      software.amazon.lambda.powertools.idempotency.exceptions.IdempotencyItemAlreadyExistsException
    • updateRecord

      public void updateRecord(software.amazon.lambda.powertools.idempotency.persistence.DataRecord record)
      Specified by:
      updateRecord in interface software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore
    • deleteRecord

      public void deleteRecord(String idempotencyKey)
      Specified by:
      deleteRecord in interface software.amazon.lambda.powertools.idempotency.persistence.PersistenceStore