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.
---