Interface IdempotencyRecordRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<IdempotencyRecord,String>, org.springframework.data.jpa.repository.JpaRepository<IdempotencyRecord,String>, org.springframework.data.repository.ListCrudRepository<IdempotencyRecord,String>, org.springframework.data.repository.ListPagingAndSortingRepository<IdempotencyRecord,String>, org.springframework.data.repository.PagingAndSortingRepository<IdempotencyRecord,String>, org.springframework.data.repository.query.QueryByExampleExecutor<IdempotencyRecord>, org.springframework.data.repository.Repository<IdempotencyRecord,String>

public interface IdempotencyRecordRepository extends org.springframework.data.jpa.repository.JpaRepository<IdempotencyRecord,String>
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
     
    boolean
     
    int
     
    int
     

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

    count, exists, findAll, findBy, findOne
  • Method Details

    • existsByKeyAndNotExpired

      @Query(nativeQuery=true, value=" select\n count(r) > 0\n from\n engine.idempotency_records r\n where\n r.key = :key\n and r.expires_at >= now()\n") boolean existsByKeyAndNotExpired(String key)
    • insertIfNotExistsOrUpdateIfExpired

      @Modifying @Query(nativeQuery=true, value=" insert into\n engine.idempotency_records as r\n (key, data, created_at, expires_at)\n values (\n :key,\n :data ::json,\n now(),\n now() + make_interval(secs => :ttl)\n )\n on conflict (key) do update\n set\n data = :data ::json,\n created_at = now(),\n expires_at = now() + make_interval(secs => :ttl)\n where\n r.expires_at < now()\n") int insertIfNotExistsOrUpdateIfExpired(String key, String data, int ttl)
    • insertIfNotExistsOrUpdateIfExpired

      @Modifying @Query(nativeQuery=true, value=" insert into\n engine.idempotency_records as r\n (key, data, created_at, expires_at)\n values (\n :key,\n :data ::json,\n now(),\n now() + ( :ttl )::interval\n )\n on conflict (key) do update\n set\n data = :data ::json,\n created_at = now(),\n expires_at = now() + ( :ttl )::interval\n where\n r.expires_at < now()\n") int insertIfNotExistsOrUpdateIfExpired(String key, String data, String ttl)
    • deleteExpired

      @Modifying @Query(nativeQuery=true, value=" delete from engine.idempotency_records r where r.expires_at < now()\n") void deleteExpired()
    • deleteByKeyAndNotExpired

      @Modifying @Query(nativeQuery=true, value=" delete from\n engine.idempotency_records r\n where\n r.key = :key\n and r.expires_at >= now()\n") int deleteByKeyAndNotExpired(String key)