lib/picky/backends/redis.rb in picky-3.2.0 vs lib/picky/backends/redis.rb in picky-3.3.0
- old
+ new
@@ -7,38 +7,44 @@
class Redis < Backend
attr_reader :client
def initialize options = {}
+ super options
+
require 'redis'
@client = options[:client] || ::Redis.new(:db => (options[:db] || 15))
rescue LoadError => e
warn_gem_missing 'redis', 'the Redis client'
end
# Returns an object that on #initial, #load returns an object that responds to:
# [:token] # => [id, id, id, id, id] (an array of ids)
#
def create_inverted bundle
- List.new client, "#{bundle.identifier}:inverted"
+ extract_lambda_or(inverted, client, bundle) ||
+ List.new(client, "#{bundle.identifier}:inverted")
end
# Returns an object that on #initial, #load returns an object that responds to:
# [:token] # => 1.23 (a weight)
#
def create_weights bundle
- Float.new client, "#{bundle.identifier}:weights"
+ extract_lambda_or(weights, client, bundle) ||
+ Float.new(client, "#{bundle.identifier}:weights")
end
# Returns an object that on #initial, #load returns an object that responds to:
# [:encoded] # => [:original, :original] (an array of original symbols this similarity encoded thing maps to)
#
def create_similarity bundle
- List.new client, "#{bundle.identifier}:similarity"
+ extract_lambda_or(similarity, client, bundle) ||
+ List.new(client, "#{bundle.identifier}:similarity")
end
# Returns an object that on #initial, #load returns an object that responds to:
# [:key] # => value (a value for this config key)
#
def create_configuration bundle
- String.new client, "#{bundle.identifier}:configuration"
+ extract_lambda_or(configuration, client, bundle) ||
+ String.new(client, "#{bundle.identifier}:configuration")
end
# Returns the result ids for the allocation.
#
# Developers wanting to program fast intersection
\ No newline at end of file