Interface CachedResponseRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<CachedResponse, String>, org.springframework.data.repository.ListCrudRepository<CachedResponse, String>, org.springframework.data.repository.ListPagingAndSortingRepository<CachedResponse, String>, org.springframework.data.mongodb.repository.MongoRepository<CachedResponse, String>, org.springframework.data.repository.PagingAndSortingRepository<CachedResponse, String>, org.springframework.data.repository.query.QueryByExampleExecutor<CachedResponse>, org.springframework.data.repository.Repository<CachedResponse, String>

@Repository public interface CachedResponseRepository extends org.springframework.data.mongodb.repository.MongoRepository<CachedResponse, String>
Mongo repository ("collection") for CachedResponse documents.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Deletes every cached response last accessed before cutoff, plus any with no lastAccessedAt at all (documents cached before that field existed; in a Mongo query, null matches a missing field).
     

    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.repository.ListCrudRepository

    findAll, findAllById, saveAll

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

    findAll

    Methods inherited from interface org.springframework.data.mongodb.repository.MongoRepository

    findAll, findAll, insert, insert

    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

    • findByRequestPath

      Optional<CachedResponse> findByRequestPath(String requestPath)
    • deleteNotAccessedSince

      @DeleteQuery("{ '$or': [ { 'lastAccessedAt': { '$lt': ?0 } }, { 'lastAccessedAt': null } ] }") long deleteNotAccessedSince(Instant cutoff)
      Deletes every cached response last accessed before cutoff, plus any with no lastAccessedAt at all (documents cached before that field existed; in a Mongo query, null matches a missing field). Deleting a live entry only costs one extra upstream request the next time it's asked for, so treating "unknown" as "stale" is safe.
      Returns:
      the number of documents deleted