user619804
user619804

Reputation: 2356

ReactiveRedisTemplate List Operations - set Expire and TTL

This integration test uses ReactiveRedisTemplate list operations to:

  1. push a List to the cache using the ReactiveRedisTemplate list operation leftPushAll()

  2. retrieves the List as a flux from the cache using the ReactiveRedisTemplate list operation range() to retrieve all elements of the list from index 0 to the last index in the list

      public void givenList_whenLeftPushAndRange_thenPopCatalog() {
        //catalog is a List<Catalog> of size 367
        Mono<Long> lPush = reactiveListOps.leftPushAll(LIST_NAME, catalog).log("Pushed");
    
        StepVerifier.create(lPush).expectNext(367L).verifyComplete();
    
        Mono<Long> sz = reactiveListOps.size(LIST_NAME);
        Long listsz = sz.block();
        assert listsz != null;
        Assert.assertEquals(listsz.intValue(), catalog.size());
    
        Flux<Catalog> catalogFlux =
            reactiveListOps
                .range(LIST_NAME, 0, listsz)
                .map(
                    c -> {
                      System.out.println(c.getOffset());
                      return c;
                    })
                .log("Fetched Catalog");
    
        List<Catalog> catalogList = catalogFlux.collectList().block();
        assert catalogList != null;
        Assert.assertEquals(catalogList.size(), catalog.size());
      }
    
    
    

This test works fine. My question is - how is the EXPIRY and TTL of these List objects stored in the cache controlled?

The reason I ask - is on my local Redis server, I notice they remain in the cache for a number of hours, but when I run this code against a Redis server hosted on AWS, the List objects only seem to remain in the cache for 30 minutes.

Is there a configuration property that can be used to control the TTL of list objects?

Thank you, ideally I'd like to have more control over how long these objects remain in the cache.

Upvotes: 1

Views: 709

Answers (0)

Related Questions