You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Chris Schwarzfischer (JIRA)" <ji...@apache.org> on 2019/04/08 11:11:00 UTC

[jira] [Created] (CAMEL-13397) RedisStringIdempotentRepository resetting expiry on existing keys

Chris Schwarzfischer created CAMEL-13397:
--------------------------------------------

             Summary: RedisStringIdempotentRepository resetting expiry on existing keys
                 Key: CAMEL-13397
                 URL: https://issues.apache.org/jira/browse/CAMEL-13397
             Project: Camel
          Issue Type: Bug
          Components: camel-spring-redis
    Affects Versions: 2.23.1
            Reporter: Chris Schwarzfischer


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 the frequency of add is higher that the expiry time.

 
{code:java}
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;
}{code}
this should probably rather be:
{code:java}
public boolean add(String key) {
    boolean added = valueOperations.setIfAbsent(createRedisKey(key), key);
    if (expiry > 0 && added) {
        valueOperations.getOperations().expire(createRedisKey(key), expiry, TimeUnit.SECONDS);
    }
    return added;
}{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)