Package io.meeds.commons.digest.dao
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 -
Method Summary
Modifier and TypeMethodDescriptionfindByDailyTrueAndDailyLastSentBeforeAndIdGreaterThanOrderByIdAsc(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 nothingfindByUserId(String userId) 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 offindByWeeklyTrueAndWeeklyLastSentBeforeAndIdGreaterThanOrderByIdAsc(Instant cutoff, long afterId, org.springframework.data.domain.Limit limit) The weekly candidates of the sender job, same keyset read as the daily oneintupdateDailyWatermark(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.intupdateWeeklyWatermark(long id, Instant expected, Instant value) Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Field Details
-
UPDATE_DAILY_WATERMARK_QUERY
- See Also:
-
UPDATE_WEEKLY_WATERMARK_QUERY
- See Also:
-
-
Method Details
-
findByUserId
-
findByUserIdIn
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
-