Sha256: c82e986a7877bae265c400f897aff2d65d57fe25e1685aaf70cd4225b152119f

Contents?: true

Size: 832 Bytes

Versions: 11

Compression:

Stored size: 832 Bytes

Contents

module Internals

  module Index

    class Redis

      class ListHash < Basic

        # Writes the hash into Redis.
        #
        def dump hash
          hash.each_pair do |key, values|
            redis_key = "#{namespace}:#{key}"
            i = 0
            backend.multi do
              backend.del redis_key

              values.each do |value|
                i += 1
                backend.zadd redis_key, i, value
              end
            end
          end
        end

        # Get a collection.
        #
        def collection sym
          backend.lrange "#{namespace}:#{sym}", 0, -1
        end

        # Get a single value.
        #
        def member sym
          raise "Can't retrieve a single value from a Redis ListHash. Use Index::Redis::StringHash."
        end

      end

    end

  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

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