[
https://issues.apache.org/jira/browse/CAMEL-13397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Chris Schwarzfischer updated CAMEL-13397:
-----------------------------------------
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.
{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}
was:
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}
> 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
> Priority: Major
>
> 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) {
> 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)