Skip to content

A platform for community discussion. Free, open, simple.

PERF: Skip running 'auto_leave' during every PresenceChannel method (#15970)

David Taylore945f301d109
diff --git a/lib/presence_channel.rb b/lib/presence_channel.rb
index 757da7c9912..82c9db540b6 100644
--- a/lib/presence_channel.rb
+++ b/lib/presence_channel.rb
@@ -129,8 +129,6 @@ class PresenceChannel
release_mutex(mutex_value)
end
end
-
- auto_leave
end
# Immediately mark a user's client as leaving the channel
@@ -151,16 +149,12 @@ class PresenceChannel
release_mutex(mutex_value)
end
end
-
- auto_leave
end
# Fetch a {PresenceChannel::State} instance representing the current state of this
#
# @param [Boolean] count_only set true to skip fetching the list of user ids from redis
def state(count_only: config.count_only)
- auto_leave
-
if count_only
last_id, count = retry_on_mutex_error do
PresenceChannel.redis_eval(
diff --git a/spec/components/presence_channel_spec.rb b/spec/components/presence_channel_spec.rb
index 1508f790146..09996c567af 100644
--- a/spec/components/presence_channel_spec.rb
+++ b/spec/components/presence_channel_spec.rb
@@ -74,6 +74,8 @@ describe PresenceChannel do
freeze_time Time.zone.now + 1 + PresenceChannel::DEFAULT_TIMEOUT
+ Jobs::PresenceChannelAutoLeave.new.execute({})
+
expect(channel.count).to eq(0)
end