Sha256: 221e64275c44e88ccdc0d36b2bffdc3a4d7d704204dd7568bf316a6780f14879

Contents?: true

Size: 776 Bytes

Versions: 7

Compression:

Stored size: 776 Bytes

Contents

module Picky

  module Backend

    class Redis

      class StringHash < Basic

        # Writes the hash into Redis.
        #
        # Note: We could use multi, but it did not help.
        #
        def dump hash
          clear
          hash.each_pair do |key, value|
            backend.hset namespace, key, value
          end
        end

        # Clears the hash.
        #
        def clear
          backend.del namespace
        end

        # Get a collection.
        #
        def collection key
          raise "Can't retrieve collection for :#{key} from a StringHash. Use Indexes::Redis::ListHash."
        end

        # Get a single value.
        #
        def member key
          backend.hget namespace, key
        end

      end

    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
picky-3.0.1 lib/picky/backend/redis/string_hash.rb
picky-3.0.0 lib/picky/backend/redis/string_hash.rb
picky-3.0.0.pre5 lib/picky/backend/redis/string_hash.rb
picky-3.0.0.pre4 lib/picky/backend/redis/string_hash.rb
picky-3.0.0.pre3 lib/picky/backend/redis/string_hash.rb
picky-3.0.0.pre2 lib/picky/backend/redis/string_hash.rb
picky-3.0.0.pre1 lib/picky/backend/redis/string_hash.rb