[ 
https://issues.apache.org/jira/browse/NIFI-4987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16484237#comment-16484237
 ] 

ASF GitHub Bot commented on NIFI-4987:
--------------------------------------

Github user bbende commented on the issue:

    https://github.com/apache/nifi/pull/2726
  
    The TTL concept is really specific to the implementation (Redis in this 
case). From the perspective of the DMC interface, the API for getAndPutIfAbsent 
is saying it will only do a put if the key wasn't there. So I wouldn't really 
expect anything about the key to change unless the put was performed, so I lean 
towards not updating the TTL when the key was already there because to me the 
TTL is part of the put which didn't happen.
    
    The current logic in PutDistributedMapCache looks like if "keep original" 
is chosen and there is an existing value for the key, then it routes to 
failure, so I don't think that should be changed unless someone believes that 
is a bug and wasn't the intended behavior.
    
    I was also looking at the commands again, and I noticed this as another way 
to do a put-if-absent with TTL:
    
    `redisConnection.set(kv.getKey(), kv.getValue(), 
Expiration.milliseconds(-1), RedisStringCommands.SetOption.ifAbsent());`
    
    The only issue is that "setnx" returns a boolean that tells us if the set 
was done which we check after the transaction is done, and "set" is void, so 
I'm not sure if it is better to just use setnx + expire. You'll have to play 
with it to see how it works out.


> Support TTL in Redis
> --------------------
>
>                 Key: NIFI-4987
>                 URL: https://issues.apache.org/jira/browse/NIFI-4987
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: Brian Ghigiarelli
>            Assignee: Sivaprasanna Sethuraman
>            Priority: Minor
>
> To properly integrate the NiFi with Redis, it would be nice to support 
> setting TTLs for keys, whether a global TTL is used for the particular Redis 
> database, or a configurable TTL is used for each key. At the moment, the 
> PutDistributedMapCache processor that uses the 
> RedisDistributedMapCacheClientService and calls to the 
> RedisConnectionPoolService does not pass in any TTL / EXPIRE parameter, so 
> Redis will cache the value potentially forever unless Redis itself clears the 
> key based on its configured maxmemory eviction strategy.
> On 
> [SO|https://stackoverflow.com/questions/49321005/setting-ttl-on-redis-with-apache-nifi-putdistributedmapcache/49324205#49324205],
>  [~bbende] suggested either a PutRedis processor or a modification to the 
> RedisDistributedMapCacheClientService.



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

Reply via email to