NIFI-7373 Setting TTL on keys in Redis putAll

This closes #4217.
This commit is contained in:
Bryan Bende 2020-07-23 07:37:36 -04:00
parent 0e61dbc9a0
commit 99b3780ad9
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 8 additions and 0 deletions

View File

@ -211,6 +211,9 @@ public class RedisDistributedMapCacheClientService extends AbstractControllerSer
if (!values.isEmpty()) {
redisConnection.mSet(values);
if (ttl != -1L) {
values.keySet().forEach(k -> redisConnection.expire(k, ttl));
}
}
return null;
});
@ -323,6 +326,11 @@ public class RedisDistributedMapCacheClientService extends AbstractControllerSer
// if we use set(k, newVal) then the results list will always have size == 0 b/c when convertPipelineAndTxResults is set to true,
// status responses like "OK" are skipped over, so by using getSet we can rely on the results list to know if the transaction succeeded
redisConnection.getSet(k, newVal);
// set the TTL if specified
if (ttl != -1L) {
redisConnection.expire(k, ttl);
}
}
// execute the transaction