Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flipper fails with Redis >= 4.8.0 #660

Merged
merged 6 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.25.2

* Fix deprecation warnings for Redis >= 4.8.0 (https://github.com/jnunemaker/flipper/pull/660)

## 0.25.1

### Additions/Changes
Expand Down
16 changes: 14 additions & 2 deletions lib/flipper/adapters/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,21 @@ def features

# Public: Adds a feature to the set of known features.
def add(feature)
@client.sadd FeaturesKey, feature.key
if redis_sadd_returns_boolean?
@client.sadd? FeaturesKey, feature.key
else
@client.sadd FeaturesKey, feature.key
end
true
end

# Public: Removes a feature from the set of known features.
def remove(feature)
@client.srem FeaturesKey, feature.key
if redis_sadd_returns_boolean?
@client.srem? FeaturesKey, feature.key
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at https://github.com/mperham/sidekiq/issues 5484 I guess we could have

-          @client.srem FeaturesKey, feature.key
+          @client.srem FeaturesKey, [feature.key]

I'm no redis expert, though

else
@client.srem FeaturesKey, feature.key
end
@client.del feature.key
true
end
Expand Down Expand Up @@ -109,6 +117,10 @@ def disable(feature, gate, thing)

private

def redis_sadd_returns_boolean?
::Redis.respond_to?(:sadd_returns_boolean) && ::Redis.sadd_returns_boolean
end

def read_many_features(features)
docs = docs_for(features)
result = {}
Expand Down
1 change: 1 addition & 0 deletions spec/flipper/adapters/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

options[:url] = ENV['REDIS_URL'] if ENV['REDIS_URL']

Redis.raise_deprecations = true
Redis.new(options)
end

Expand Down