diff --git a/app/lib/delivery_failure_tracker.rb b/app/lib/delivery_failure_tracker.rb index 66c1fd8c00..e27f29129f 100644 --- a/app/lib/delivery_failure_tracker.rb +++ b/app/lib/delivery_failure_tracker.rb @@ -10,7 +10,7 @@ class DeliveryFailureTracker end def track_failure! - redis.sadd(exhausted_deliveries_key, today) + redis.sadd?(exhausted_deliveries_key, today) UnavailableDomain.create(domain: @host) if reached_failure_threshold? end diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 9fe9ec346d..8dc4a8c96e 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -322,24 +322,24 @@ class FeedManager def clean_feeds!(type, ids) reblogged_id_sets = {} - redis.pipelined do + redis.pipelined do |pipeline| ids.each do |feed_id| - redis.del(key(type, feed_id)) + pipeline.del(key(type, feed_id)) reblog_key = key(type, feed_id, 'reblogs') # We collect a future for this: we don't block while getting # it, but we can iterate over it later. - reblogged_id_sets[feed_id] = redis.zrange(reblog_key, 0, -1) - redis.del(reblog_key) + reblogged_id_sets[feed_id] = pipeline.zrange(reblog_key, 0, -1) + pipeline.del(reblog_key) end end # Remove all of the reblog tracking keys we just removed the # references to. - redis.pipelined do + redis.pipelined do |pipeline| reblogged_id_sets.each do |feed_id, future| future.value.each do |reblogged_id| reblog_set_key = key(type, feed_id, "reblogs:#{reblogged_id}") - redis.del(reblog_set_key) + pipeline.del(reblog_set_key) end end end @@ -519,7 +519,7 @@ class FeedManager # REBLOG_FALLOFF most recent statuses, so we note that this # is an "extra" reblog, by storing it in reblog_set_key. reblog_set_key = key(timeline_type, account_id, "reblogs:#{status.reblog_of_id}") - redis.sadd(reblog_set_key, status.id) + redis.sadd?(reblog_set_key, status.id) return false end else @@ -556,7 +556,7 @@ class FeedManager # 2. Remove reblog from set of this status's reblogs. reblog_set_key = key(timeline_type, account_id, "reblogs:#{status.reblog_of_id}") - redis.srem(reblog_set_key, status.id) + redis.srem?(reblog_set_key, status.id) redis.zrem(reblog_key, status.reblog_of_id) # 3. Re-insert another reblog or original into the feed if one # remains in the set. We could pick a random element, but this diff --git a/app/lib/vacuum/statuses_vacuum.rb b/app/lib/vacuum/statuses_vacuum.rb index d1c4e71973..e6237374be 100644 --- a/app/lib/vacuum/statuses_vacuum.rb +++ b/app/lib/vacuum/statuses_vacuum.rb @@ -42,6 +42,6 @@ class Vacuum::StatusesVacuum end def remove_from_search_index(status_ids) - with_redis { |redis| redis.sadd('chewy:queue:StatusesIndex', status_ids) } + with_redis { |redis| redis.sadd?('chewy:queue:StatusesIndex', status_ids) } end end diff --git a/app/models/follow_recommendation_suppression.rb b/app/models/follow_recommendation_suppression.rb index 170506b853..3b503c9c70 100644 --- a/app/models/follow_recommendation_suppression.rb +++ b/app/models/follow_recommendation_suppression.rb @@ -19,9 +19,9 @@ class FollowRecommendationSuppression < ApplicationRecord private def remove_follow_recommendations - redis.pipelined do + redis.pipelined do |pipeline| I18n.available_locales.each do |locale| - redis.zrem("follow_recommendations:#{locale}", account_id) + pipeline.zrem("follow_recommendations:#{locale}", account_id) end end end diff --git a/app/models/trends/base.rb b/app/models/trends/base.rb index a189f11f23..3d4f01049f 100644 --- a/app/models/trends/base.rb +++ b/app/models/trends/base.rb @@ -60,7 +60,7 @@ class Trends::Base end def record_used_id(id, at_time = Time.now.utc) - redis.sadd(used_key(at_time), id) + redis.sadd?(used_key(at_time), id) redis.expire(used_key(at_time), 1.day.seconds) end diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb index 2b649ee222..4f68fc6c44 100644 --- a/app/services/batched_remove_status_service.rb +++ b/app/services/batched_remove_status_service.rb @@ -48,9 +48,9 @@ class BatchedRemoveStatusService < BaseService # Cannot be batched @status_id_cutoff = Mastodon::Snowflake.id_at(2.weeks.ago) - redis.pipelined do + redis.pipelined do |pipeline| statuses.each do |status| - unpush_from_public_timelines(status) + unpush_from_public_timelines(pipeline, status) end end end @@ -73,22 +73,22 @@ class BatchedRemoveStatusService < BaseService end end - def unpush_from_public_timelines(status) + def unpush_from_public_timelines(pipeline, status) return unless status.public_visibility? && status.id > @status_id_cutoff payload = Oj.dump(event: :delete, payload: status.id.to_s) - redis.publish('timeline:public', payload) - redis.publish(status.local? ? 'timeline:public:local' : 'timeline:public:remote', payload) + pipeline.publish('timeline:public', payload) + pipeline.publish(status.local? ? 'timeline:public:local' : 'timeline:public:remote', payload) if status.media_attachments.any? - redis.publish('timeline:public:media', payload) - redis.publish(status.local? ? 'timeline:public:local:media' : 'timeline:public:remote:media', payload) + pipeline.publish('timeline:public:media', payload) + pipeline.publish(status.local? ? 'timeline:public:local:media' : 'timeline:public:remote:media', payload) end status.tags.map { |tag| tag.name.mb_chars.downcase }.each do |hashtag| - redis.publish("timeline:hashtag:#{hashtag}", payload) - redis.publish("timeline:hashtag:#{hashtag}:local", payload) if status.local? + pipeline.publish("timeline:hashtag:#{hashtag}", payload) + pipeline.publish("timeline:hashtag:#{hashtag}:local", payload) if status.local? end end diff --git a/app/workers/scheduler/indexing_scheduler.rb b/app/workers/scheduler/indexing_scheduler.rb index c423966297..d0c5c8f861 100644 --- a/app/workers/scheduler/indexing_scheduler.rb +++ b/app/workers/scheduler/indexing_scheduler.rb @@ -16,7 +16,7 @@ class Scheduler::IndexingScheduler type.import!(ids) redis.pipelined do |pipeline| - ids.each { |id| pipeline.srem("chewy:queue:#{type.name}", id) } + ids.each { |id| pipeline.srem?("chewy:queue:#{type.name}", id) } end end end diff --git a/lib/chewy/strategy/mastodon.rb b/lib/chewy/strategy/mastodon.rb index ee8b921865..0be98f6a35 100644 --- a/lib/chewy/strategy/mastodon.rb +++ b/lib/chewy/strategy/mastodon.rb @@ -17,7 +17,7 @@ module Chewy RedisConfiguration.with do |redis| redis.pipelined do |pipeline| @stash.each do |type, ids| - pipeline.sadd("chewy:queue:#{type.name}", ids) + pipeline.sadd?("chewy:queue:#{type.name}", ids) end end end diff --git a/lib/mastodon/feeds_cli.rb b/lib/mastodon/feeds_cli.rb index 428d63a446..ebdb6fee47 100644 --- a/lib/mastodon/feeds_cli.rb +++ b/lib/mastodon/feeds_cli.rb @@ -54,8 +54,8 @@ module Mastodon def clear keys = redis.keys('feed:*') - redis.pipelined do - keys.each { |key| redis.del(key) } + redis.pipelined do |pipeline| + keys.each { |key| pipeline.del(key) } end say('OK', :green) diff --git a/spec/lib/delivery_failure_tracker_spec.rb b/spec/lib/delivery_failure_tracker_spec.rb index c8179ebd91..dee9e39bf2 100644 --- a/spec/lib/delivery_failure_tracker_spec.rb +++ b/spec/lib/delivery_failure_tracker_spec.rb @@ -22,7 +22,7 @@ describe DeliveryFailureTracker do describe '#track_failure!' do it 'marks URL as unavailable after 7 days of being called' do - 6.times { |i| redis.sadd('exhausted_deliveries:example.com', i) } + 6.times { |i| redis.sadd?('exhausted_deliveries:example.com', i) } subject.track_failure! expect(subject.days).to eq 7 diff --git a/spec/lib/vacuum/feeds_vacuum_spec.rb b/spec/lib/vacuum/feeds_vacuum_spec.rb index 0aec26740f..438eaa6b45 100644 --- a/spec/lib/vacuum/feeds_vacuum_spec.rb +++ b/spec/lib/vacuum/feeds_vacuum_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Vacuum::FeedsVacuum do redis.zadd(feed_key_for(inactive_user), 1, 1) redis.zadd(feed_key_for(active_user), 1, 1) redis.zadd(feed_key_for(inactive_user, 'reblogs'), 2, 2) - redis.sadd(feed_key_for(inactive_user, 'reblogs:2'), 3) + redis.sadd?(feed_key_for(inactive_user, 'reblogs:2'), 3) subject.perform end