Sha256: 0d524fb104cced0e772eb937a4d023c34af8a4b31463094f61101934f4e80c41

Contents?: true

Size: 952 Bytes

Versions: 34

Compression:

Stored size: 952 Bytes

Contents

module Picky

  module Backends

    class Redis

      class List < Basic

        # Writes the hash into Redis.
        #
        def dump hash
          clear
          hash.each_pair do |key, values|
            redis_key = "#{namespace}:#{key}"
            i = 0
            values.each do |value|
              i += 1
              client.zadd redis_key, i, value
            end
          end
        end

        # Clear the index for this list.
        #
        # Note: Perhaps we can use a server only command.
        #       This is not the optimal way to do it.
        #
        def clear
          redis_key = "#{namespace}:*"
          client.keys(redis_key).each do |key|
            client.del key
          end
        end

        # Get a collection.
        #
        # Internal API method for the index.
        #
        def [] key
          client.zrange "#{namespace}:#{key}", 0, -1
        end

      end

    end

  end

end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
picky-3.6.7 lib/picky/backends/redis/list.rb
picky-3.6.6 lib/picky/backends/redis/list.rb
picky-3.6.4 lib/picky/backends/redis/list.rb
picky-3.6.3 lib/picky/backends/redis/list.rb
picky-3.6.2 lib/picky/backends/redis/list.rb
picky-3.6.1 lib/picky/backends/redis/list.rb
picky-3.6.0 lib/picky/backends/redis/list.rb
picky-3.5.4 lib/picky/backends/redis/list.rb
picky-3.5.3 lib/picky/backends/redis/list.rb
picky-3.5.2 lib/picky/backends/redis/list.rb
picky-3.5.1 lib/picky/backends/redis/list.rb
picky-3.5.0 lib/picky/backends/redis/list.rb
picky-3.4.3 lib/picky/backends/redis/list.rb
picky-3.4.2 lib/picky/backends/redis/list.rb
picky-3.4.1 lib/picky/backends/redis/list.rb
picky-3.4.0 lib/picky/backends/redis/list.rb
picky-3.3.3 lib/picky/backends/redis/list.rb
picky-3.3.2 lib/picky/backends/redis/list.rb
picky-3.3.1 lib/picky/backends/redis/list.rb
picky-3.3.0 lib/picky/backends/redis/list.rb