Class: SidekiqUniqueJobs::Redis::Hash
- Defined in:
- lib/sidekiq_unique_jobs/redis/hash.rb
Overview
Class Hash provides convenient access to redis hashes
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#[](member) ⇒ Object
Get a members value.
-
#count ⇒ Integer
Returns the count for this hash.
-
#del(*fields) ⇒ Object
Removes the key from redis.
-
#entries(with_values: false) ⇒ Array<Object>, Hash<String, String>
Return entries for this hash.
Methods inherited from Entity
#exist?, #expires?, #initialize, #pttl, #ttl
Methods included from Timing
clock_stamp, now_f, time_source, timed
Methods included from JSON
dump_json, load_json, safe_load_json
Methods included from Script::Caller
call_script, debug_lua, do_call, extract_args, max_history, normalize_argv, now_f, redis_version
Methods included from Logging
#build_message, included, #log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger, #logging_context, #with_configured_loggers_context, #with_logging_context
Constructor Details
This class inherits a constructor from SidekiqUniqueJobs::Redis::Entity
Instance Method Details
#[](member) ⇒ Object
Get a members value
41 42 43 |
# File 'lib/sidekiq_unique_jobs/redis/hash.rb', line 41 def [](member) redis { |conn| conn.hget(key, member) } end |
#count ⇒ Integer
Returns the count for this hash
51 52 53 |
# File 'lib/sidekiq_unique_jobs/redis/hash.rb', line 51 def count redis { |conn| conn.hlen(key) } end |
#del(*fields) ⇒ Object
Removes the key from redis
30 31 32 |
# File 'lib/sidekiq_unique_jobs/redis/hash.rb', line 30 def del(*fields) redis { |conn| conn.hdel(key, *fields) } end |
#entries(with_values: false) ⇒ Array<Object>, Hash<String, String>
Return entries for this hash
19 20 21 22 23 24 25 |
# 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 |