lib/picky/backend/redis.rb in picky-2.7.0 vs lib/picky/backend/redis.rb in picky-3.0.0.pre1
- old
+ new
@@ -1,39 +1,43 @@
-module Backend
+module Picky
- #
- #
- class Redis < Base
+ module Backend
- def initialize bundle_name, category
- super bundle_name, category
+ #
+ #
+ class Redis < Base
- # Refine a few Redis "types".
+ def initialize bundle
+ super bundle
+
+ # Refine a few Redis "types".
+ #
+ @inverted = Redis::ListHash.new "#{bundle.identifier}:inverted"
+ @weights = Redis::StringHash.new "#{bundle.identifier}:weights"
+ @similarity = Redis::ListHash.new "#{bundle.identifier}:similarity"
+ @configuration = Redis::StringHash.new "#{bundle.identifier}:configuration"
+ end
+
+ # Delegate to the right collection.
#
- @inverted = Redis::ListHash.new "#{category.identifier}:#{bundle_name}:inverted"
- @weights = Redis::StringHash.new "#{category.identifier}:#{bundle_name}:weights"
- @similarity = Redis::ListHash.new "#{category.identifier}:#{bundle_name}:similarity"
- @configuration = Redis::StringHash.new "#{category.identifier}:#{bundle_name}:configuration"
- end
+ def ids sym
+ inverted.collection sym
+ end
- # Delegate to the right collection.
- #
- def ids sym
- inverted.collection sym
- end
+ # Delegate to the right member value.
+ #
+ # Note: Converts to float.
+ #
+ def weight sym
+ weights.member(sym).to_f
+ end
- # Delegate to the right member value.
- #
- # Note: Converts to float.
- #
- def weight sym
- weights.member(sym).to_f
- end
+ # Delegate to a member value.
+ #
+ def setting sym
+ configuration.member sym
+ end
- # Delegate to a member value.
- #
- def setting sym
- configuration.member sym
end
end
end
\ No newline at end of file