[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-23 Thread bbende
Github user bbende commented on the issue:

https://github.com/apache/nifi/pull/2726
  
Looks good, merged, thanks!


---


[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-22 Thread bbende
Github user bbende commented on the issue:

https://github.com/apache/nifi/pull/2726
  
@zenfenan thanks for the updates, I think there is also a small changed 
needed in putIfAbsent correct? If setnx returns true then set expire?


---


[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-22 Thread zenfenan
Github user zenfenan commented on the issue:

https://github.com/apache/nifi/pull/2726
  
@bbende I have made the changes.


---


[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-22 Thread bbende
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.


---


[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-21 Thread bbende
Github user bbende commented on the issue:

https://github.com/apache/nifi/pull/2726
  
Was looking into this a little more and I believe we can keep all of the 
origin getAndPutIfAbsent, and just add the following right after the set:

`redisConnection.expire(kv.getKey(), 1000);`

Replacing 1000 with whatever time variable.


---


[GitHub] nifi issue #2726: NIFI-4987: Added TTL to RedisDistributedMapCacheClientServ...

2018-05-21 Thread bbende
Github user bbende commented on the issue:

https://github.com/apache/nifi/pull/2726
  
@zenfenan the getAndPutIfAbsent method needs to be an atomic operation 
which is the reason we are using the watch and multi step operation so we can't 
remove that


---