Sha256: 49cba27baa4571f5eb483d33696f6af531ca2d5cbf4b30a2ecedf76bc2350ebc
Contents?: true
Size: 1.25 KB
Versions: 61
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module SidekiqUniqueJobs module Redis # # Class Hash provides convenient access to redis hashes # # @author Mikael Henriksson <mikael@mhenrixon.com> # class Hash < Entity # # Return entries for this hash # # @param [true,false] with_values false return hash # # @return [Array<Object>] when given with_values: false # @return [Hash<String, String>] when given with_values: true # def entries(with_values: false) if with_values redis { |conn| conn.hgetall(key) } else redis { |conn| conn.hkeys(key) } end end # # Removes the key from redis # def del(*fields) redis { |conn| conn.hdel(key, *fields) } end # # Get a members value # # @param [String] member the member who's value to get # # @return [Object] whatever is stored on this hash member # def [](member) redis { |conn| conn.hget(key, member) } end # # Returns the count for this hash # # # @return [Integer] the length of this hash # def count redis { |conn| conn.hlen(key) } end end end end
Version data entries
61 entries across 61 versions & 1 rubygems