Skip to content

Commit f16a4bb

Browse files
authored
Merge pull request #38 from prog-supdex/fix/add-prefix-to-cleaner
fix: consider redis_prefix in GraphQL::AnyCable::Cleaner
2 parents 8391875 + 026f543 commit f16a4bb

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

lib/graphql/anycable/cleaner.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def clean_channels
1616
return unless config.subscription_expiration_seconds
1717
return unless config.use_redis_object_on_cleanup
1818

19-
redis.scan_each(match: "#{adapter::CHANNEL_PREFIX}*") do |key|
19+
redis.scan_each(match: "#{redis_key(adapter::CHANNEL_PREFIX)}*") do |key|
2020
idle = redis.object("IDLETIME", key)
2121
next if idle&.<= config.subscription_expiration_seconds
2222

@@ -28,7 +28,7 @@ def clean_subscriptions
2828
return unless config.subscription_expiration_seconds
2929
return unless config.use_redis_object_on_cleanup
3030

31-
redis.scan_each(match: "#{adapter::SUBSCRIPTION_PREFIX}*") do |key|
31+
redis.scan_each(match: "#{redis_key(adapter::SUBSCRIPTION_PREFIX)}*") do |key|
3232
idle = redis.object("IDLETIME", key)
3333
next if idle&.<= config.subscription_expiration_seconds
3434

@@ -37,20 +37,20 @@ def clean_subscriptions
3737
end
3838

3939
def clean_fingerprint_subscriptions
40-
redis.scan_each(match: "#{adapter::SUBSCRIPTIONS_PREFIX}*") do |key|
40+
redis.scan_each(match: "#{redis_key(adapter::SUBSCRIPTIONS_PREFIX)}*") do |key|
4141
redis.smembers(key).each do |subscription_id|
42-
next if redis.exists?(adapter::SUBSCRIPTION_PREFIX + subscription_id)
42+
next if redis.exists?(redis_key(adapter::SUBSCRIPTION_PREFIX) + subscription_id)
4343

4444
redis.srem(key, subscription_id)
4545
end
4646
end
4747
end
4848

4949
def clean_topic_fingerprints
50-
redis.scan_each(match: "#{adapter::FINGERPRINTS_PREFIX}*") do |key|
50+
redis.scan_each(match: "#{redis_key(adapter::FINGERPRINTS_PREFIX)}*") do |key|
5151
redis.zremrangebyscore(key, '-inf', '0')
5252
redis.zrange(key, 0, -1).each do |fingerprint|
53-
next if redis.exists?(adapter::SUBSCRIPTIONS_PREFIX + fingerprint)
53+
next if redis.exists?(redis_key(adapter::SUBSCRIPTIONS_PREFIX) + fingerprint)
5454

5555
redis.zrem(key, fingerprint)
5656
end
@@ -70,6 +70,10 @@ def redis
7070
def config
7171
GraphQL::AnyCable.config
7272
end
73+
74+
def redis_key(prefix)
75+
"#{config.redis_prefix}-#{prefix}"
76+
end
7377
end
7478
end
7579
end

0 commit comments

Comments
 (0)