Github user ijokarumawak commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2284#discussion_r158755719
  
    --- Diff: 
nifi-nar-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/RedisDistributedMapCacheClientService.java
 ---
    @@ -187,6 +191,16 @@ public void close() throws IOException {
             });
         }
     
    +    @Override
    +    public <K, V> V removeAndGet(K key, Serializer<K> keySerializer, 
Deserializer<V> valueDeserializer) throws IOException {
    +        return withConnection(redisConnection -> {
    +            final byte[] k = serialize(key, keySerializer);
    +            final byte[] v = redisConnection.get(k);
    +            redisConnection.del(k);
    +            return valueDeserializer.deserialize(v);
    --- End diff --
    
    For multiple operations like these `get` and `del`, Redis provides 
[multi](https://redis.io/commands/multi) to make those as an atomic execution. 
Since other methods are implemented similarly, I don't have strong opinion to 
use multi here, but we can submit another JIRA for future improvement. How do 
you think?
    
    http://www.rediscookbook.org/get_and_delete.html
    
https://stackoverflow.com/questions/11148383/how-to-implement-redis-multi-exec-by-using-spring-data-redis


---

Reply via email to