Sha256: d8eb956a2a23cd3006bc0d0b8fa1d93073278324e8944847593b97161b498f05

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

module Backend

  #
  #
  class Redis < Base

    def initialize bundle_name, category
      super bundle_name, category

      # Refine a few Redis "types".
      #
      @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

    # 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 a member value.
    #
    def setting sym
      configuration.member sym
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 lib/picky/backend/redis.rb