This is an automated email from the ASF dual-hosted git repository. bbende pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git
commit 99b3780ad96df3e54584362a5d8edf6967668d2d Author: Bryan Bende <[email protected]> AuthorDate: Thu Jul 23 07:37:36 2020 -0400 NIFI-7373 Setting TTL on keys in Redis putAll This closes #4217. --- .../nifi/redis/service/RedisDistributedMapCacheClientService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java b/nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java index eb76176..45ceef2 100644 --- a/nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java +++ b/nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java @@ -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
