class SidekiqUniqueJobs::Redis::Hash

Class Hash provides convenient access to redis hashes

@author Mikael Henriksson <mikael@mhenrixon.com>

Public Instance Methods

[](member) click to toggle source

Get a members value

@param [String] member the member who's value to get

@return [Object] whatever is stored on this hash member

# File lib/sidekiq_unique_jobs/redis/hash.rb, line 41
def [](member)
  redis { |conn| conn.hget(key, member) }
end
count() click to toggle source

Returns the count for this hash

@return [Integer] the length of this hash

# File lib/sidekiq_unique_jobs/redis/hash.rb, line 51
def count
  redis { |conn| conn.hlen(key) }
end
del(*fields) click to toggle source

Removes the key from redis

# File lib/sidekiq_unique_jobs/redis/hash.rb, line 30
def del(*fields)
  redis { |conn| conn.hdel(key, *fields) }
end
entries(with_values: false) click to toggle source

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

# File lib/sidekiq_unique_jobs/redis/hash.rb, line 19
def entries(with_values: false)
  if with_values
    redis { |conn| conn.hgetall(key) }
  else
    redis { |conn| conn.hkeys(key) }
  end
end