[
https://issues.apache.org/jira/browse/NIFI-4504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16304167#comment-16304167
]
ASF GitHub Bot commented on NIFI-4504:
--------------------------------------
Github user ijokarumawak commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2284#discussion_r158756291
--- Diff:
nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-client-service-api/src/main/java/org/apache/nifi/distributed/cache/client/DistributedMapCacheClient.java
---
@@ -174,4 +189,28 @@
* @throws IOException if any error occurred while removing an entry
*/
long removeByPattern(String regex) throws IOException;
+
+ /**
+ * Removes entries whose keys match the specified pattern, and returns
a map of entries that
+ * were removed.
+ *
+ * @param <K> type of key
+ * @param <V> type of value
+ * @param regex The regular expression / pattern on which to match the
keys to be removed
+ * @param keyDeserializer key deserializer
+ * @param valueDeserializer value deserializer
+ * @return A map of key/value entries that were removed from the cache
+ * @throws IOException if any error occurred while removing an entry
+ */
+ <K, V> Map<K, V> removeByPatternAndGet(String regex, Deserializer<K>
keyDeserializer, Deserializer<V> valueDeserializer) throws IOException;
--- End diff --
This new method should have a default implementation which throws
UnsupportedOperationException.
> SimpleMapCache/PersistentMapCache: Add removeAndGet and removeByPatternAndGet
> -----------------------------------------------------------------------------
>
> Key: NIFI-4504
> URL: https://issues.apache.org/jira/browse/NIFI-4504
> Project: Apache NiFi
> Issue Type: Improvement
> Affects Versions: 1.4.0
> Reporter: Jon Kessler
> Assignee: Michael Moser
> Priority: Minor
>
> Typical map implementations return the value that was removed when performing
> a remove. Because you couldn't update the existing remove methods without it
> being a breaking change I suggest adding new versions of the remove and
> removeByPattern methods that return the removed value(s).
> These changes should also be applied up the chain to any class that makes use
> of these classes such as the MapCacheServer and
> AtomicDistributedMapCacheClient.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)