Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13397

RedisStringIdempotentRepository resetting expiry on existing keys

    XMLWordPrintableJSON

Details

    • Unknown

    Description

      When getting new input and seeing for example the same file name for the second time before expiry hits, add will simply reset the expiry to the original value independent of the set being successful or not.

      This way, the key will never expire if add is called more freuqently than the key expires.

       

      public boolean add(String key) {
          boolean added = valueOperations.setIfAbsent(createRedisKey(key), key);
          if (expiry > 0) {
              valueOperations.getOperations().expire(createRedisKey(key), expiry, TimeUnit.SECONDS);
          }
          return added;
      }

      this should probably rather be:

      public boolean add(String key) {
          return valueOperations.setIfAbsent(createRedisKey(key), key, Duration.ofSeconds(expiry));
      }

      Attachments

        Activity

          People

            acosentino Andrea Cosentino
            k1th Chris Schwarzfischer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: