aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2019-02-01 11:18:35 -0800
committerJohn Hawthorn <john@hawthorn.email>2019-02-01 12:11:22 -0800
commit211222cc182218c06e9a1b094f48d9e96e905865 (patch)
tree19a0c525ec349a5b79f867805e5b57a18117e9ff /activesupport
parentde13ed9ec740feaa5fdb48f338d36581d7ce2e3f (diff)
downloadrails-211222cc182218c06e9a1b094f48d9e96e905865.tar.gz
rails-211222cc182218c06e9a1b094f48d9e96e905865.tar.bz2
rails-211222cc182218c06e9a1b094f48d9e96e905865.zip
Keep cache for strings in notifications/fanout
When adding/removing a subscription with a string pattern, it isn't necessary to clear the entire cache, only the cache for the key being added. When adding/removing subscriptions for a regex or to match all events, the full cache is still cleared.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/notifications/fanout.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb
index 9d7fcef2c7..11721db103 100644
--- a/activesupport/lib/active_support/notifications/fanout.rb
+++ b/activesupport/lib/active_support/notifications/fanout.rb
@@ -24,10 +24,11 @@ module ActiveSupport
synchronize do
if String === pattern
@string_subscribers[pattern] << subscriber
+ @listeners_for.delete(pattern)
else
@other_subscribers << subscriber
+ @listeners_for.clear
end
- @listeners_for.clear
end
subscriber
end
@@ -37,16 +38,17 @@ module ActiveSupport
case subscriber_or_name
when String
@string_subscribers[subscriber_or_name].clear
+ @listeners_for.delete(subscriber_or_name)
else
pattern = subscriber_or_name.try(:pattern)
if String === pattern
@string_subscribers[pattern].delete(subscriber_or_name)
+ @listeners_for.delete(pattern)
else
@other_subscribers.delete(subscriber_or_name)
+ @listeners_for.clear
end
end
-
- @listeners_for.clear
end
end