dpol1 commented on code in PR #3017:
URL: https://github.com/apache/hugegraph/pull/3017#discussion_r3212997898
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedGraphTransaction.java:
##########
@@ -184,17 +185,29 @@ private void listenChanges() {
}
return false;
};
- if (graphCacheListenStatus.putIfAbsent(this.params().spaceGraphName(),
true) == null) {
- EventHub graphEventHub = this.params().graphEventHub();
+ EventHub graphEventHub = this.params().graphEventHub();
+ EventListener previous =
+ graphCacheEventListeners.putIfAbsent(
+ this.params().spaceGraphName(), listener);
+ if (previous == null) {
+ this.cacheEventListener = listener;
+ this.registeredCacheEventListener = true;
graphEventHub.listen(Events.CACHE, this.cacheEventListener);
+ } else {
+ this.cacheEventListener = previous;
+ this.registeredCacheEventListener = false;
}
}
private void unlistenChanges() {
String graphName = this.params().spaceGraphName();
- if (graphCacheListenStatus.remove(graphName) != null) {
+ if (this.registeredCacheEventListener) {
EventHub graphEventHub = this.params().graphEventHub();
- graphEventHub.unlisten(Events.CACHE, this.cacheEventListener);
+ if (graphCacheEventListeners.remove(graphName,
+ this.cacheEventListener)) {
+ graphEventHub.unlisten(Events.CACHE, this.cacheEventListener);
+ }
+ this.registeredCacheEventListener = false;
Review Comment:
Address by b77fb66
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]