[ 
https://issues.apache.org/jira/browse/CAMEL-13397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrea Cosentino resolved CAMEL-13397.
--------------------------------------
    Resolution: Fixed

> 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
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 3.0.0, 2.24.0, 3.0.0-M3, 2.23.3
>
>
> 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.
>  
> {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) {
>     return valueOperations.setIfAbsent(createRedisKey(key), key, 
> Duration.ofSeconds(expiry));
> }{code}



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

Reply via email to