Sha256: 7be57f3119248cd3fcfb6be99f7b6f8cc322026d3975503cc01ef514ecc94b93

Contents?: true

Size: 1.01 KB

Versions: 10

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, category
        super bundle_name, category

        # Refine a few Redis "types".
        #
        @index         = Redis::ListHash.new "#{category.identifier}:#{bundle_name}:index"
        @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

      # 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

10 entries across 10 versions & 1 rubygems

Version Path
picky-2.5.2 lib/picky/internals/index/redis.rb
picky-2.5.1 lib/picky/internals/index/redis.rb
picky-2.5.0 lib/picky/internals/index/redis.rb
picky-2.4.3 lib/picky/internals/index/redis.rb
picky-2.4.2 lib/picky/internals/index/redis.rb
picky-2.4.1 lib/picky/internals/index/redis.rb
picky-2.4.0 lib/picky/internals/index/redis.rb
picky-2.3.0 lib/picky/internals/index/redis.rb
picky-2.2.1 lib/picky/internals/index/redis.rb
picky-2.2.0 lib/picky/internals/index/redis.rb