Interface DigestUserDAO

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

@Repository public interface DigestUserDAO extends org.springframework.data.jpa.repository.JpaRepository<DigestUserEntity,Long>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Method Summary

    Modifier and Type
    Method
    Description
    findByDailyTrueAndDailyLastSentBeforeAndIdGreaterThanOrderByIdAsc(Instant cutoff, long afterId, org.springframework.data.domain.Limit limit)
    The daily candidates of the sender job: daily on, watermark old enough, read by keyset (ids after the last one seen, ascending) so that a candidate claimed by another node during the scan shifts nothing
     
    The enrolled users among the given ones: a row exists only for a user having a frequency enabled, so this one indexed read tells who is worth reading the settings of
    findByWeeklyTrueAndWeeklyLastSentBeforeAndIdGreaterThanOrderByIdAsc(Instant cutoff, long afterId, org.springframework.data.domain.Limit limit)
    The weekly candidates of the sender job, same keyset read as the daily one
    int
    updateDailyWatermark(long id, Instant expected, Instant value)
    The guarded update behind the claim: the watermark moves only when it still has the value the caller read, so that of two workers reading the same row, exactly one gets 1 row updated and the other 0.
    int
    updateWeeklyWatermark(long id, Instant expected, Instant value)
     

    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
  • Field Details

  • Method Details

    • findByUserId

      DigestUserEntity findByUserId(String userId)
    • findByUserIdIn

      List<DigestUserEntity> findByUserIdIn(Collection<String> userIds)
      The enrolled users among the given ones: a row exists only for a user having a frequency enabled, so this one indexed read tells who is worth reading the settings of
    • findByDailyTrueAndDailyLastSentBeforeAndIdGreaterThanOrderByIdAsc

      List<DigestUserEntity> findByDailyTrueAndDailyLastSentBeforeAndIdGreaterThanOrderByIdAsc(Instant cutoff, long afterId, org.springframework.data.domain.Limit limit)
      The daily candidates of the sender job: daily on, watermark old enough, read by keyset (ids after the last one seen, ascending) so that a candidate claimed by another node during the scan shifts nothing
    • findByWeeklyTrueAndWeeklyLastSentBeforeAndIdGreaterThanOrderByIdAsc

      List<DigestUserEntity> findByWeeklyTrueAndWeeklyLastSentBeforeAndIdGreaterThanOrderByIdAsc(Instant cutoff, long afterId, org.springframework.data.domain.Limit limit)
      The weekly candidates of the sender job, same keyset read as the daily one
    • updateDailyWatermark

      @Modifying @Query("UPDATE DigestUser u SET u.dailyLastSent = :value WHERE u.id = :id AND u.dailyLastSent = :expected") int updateDailyWatermark(@Param("id") long id, @Param("expected") Instant expected, @Param("value") Instant value)
      The guarded update behind the claim: the watermark moves only when it still has the value the caller read, so that of two workers reading the same row, exactly one gets 1 row updated and the other 0.
    • updateWeeklyWatermark

      @Modifying @Query("UPDATE DigestUser u SET u.weeklyLastSent = :value WHERE u.id = :id AND u.weeklyLastSent = :expected") int updateWeeklyWatermark(@Param("id") long id, @Param("expected") Instant expected, @Param("value") Instant value)