lib/flipper/adapters/redis.rb in flipper-redis-0.25.1 vs lib/flipper/adapters/redis.rb in flipper-redis-0.25.2
- old
+ new
@@ -26,17 +26,25 @@
read_feature_keys
end
# 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
+ else
+ @client.srem FeaturesKey, feature.key
+ end
@client.del feature.key
true
end
# Public: Clears the gate values for a feature.
@@ -106,9 +114,13 @@
true
end
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 = {}
features.zip(docs) do |feature, doc|