Sha256: 21ce5b53164216bf85c6b7d3b2e389c248ee8c4e8b1e43f3d13d832d439f8bec

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 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
      
        # TODO
        #
        @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

2 entries across 2 versions & 1 rubygems

Version Path
picky-1.4.3 lib/picky/internals/index/redis.rb
picky-1.4.2 lib/picky/internals/index/redis.rb