Sha256: 6eaa619569395c809117b7667f94ffb3191270560ab221538771b0a2fdd3d674

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

module Internals

  module Index
  
    # TODO Needs a reconnect to be run after forking.
    #
    class Redis < Backend
    
      def initialize bundle_name, config
        super bundle_name, config

        # Refine a few Redis "types".
        #
        @index         = Redis::ListHash.new "#{config.identifier}:#{bundle_name}:index"
        @weights       = Redis::StringHash.new "#{config.identifier}:#{bundle_name}:weights"
        @similarity    = Redis::ListHash.new "#{config.identifier}:#{bundle_name}:similarity"
        @configuration = Redis::StringHash.new "#{config.identifier}:#{bundle_name}:configuration"
      end
    
      # Delegate to the right collection.
      #
      def ids sym
        index.collection sym
      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
    
    end
  
  end
  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
picky-2.1.2 lib/picky/internals/index/redis.rb
picky-2.1.1 lib/picky/internals/index/redis.rb
picky-2.1.0 lib/picky/internals/index/redis.rb
picky-2.0.0 lib/picky/internals/index/redis.rb
picky-2.0.0.pre3 lib/picky/internals/index/redis.rb
picky-2.0.0.pre2 lib/picky/internals/index/redis.rb
picky-2.0.0.pre1 lib/picky/internals/index/redis.rb
picky-1.5.4 lib/picky/internals/index/redis.rb
picky-1.5.3 lib/picky/internals/index/redis.rb