Class: SidekiqUniqueJobs::LockInfo
- Inherits:
-
Redis::String
- Object
- Redis::Entity
- Redis::String
- SidekiqUniqueJobs::LockInfo
- Defined in:
- lib/sidekiq_unique_jobs/lock_info.rb
Overview
Class Info provides information about a lock
Instance Attribute Summary
Attributes inherited from Redis::Entity
Instance Method Summary collapse
-
#[](key) ⇒ Object
Quick access to the hash members for the value.
-
#none? ⇒ Boolean
Check if this redis string is blank.
-
#present? ⇒ Boolean
Check if this redis string has a value.
-
#set(obj, pipeline = nil) ⇒ Hash
Writes the lock info to redis.
-
#value ⇒ Hash
Returns the value for this key as a hash.
Methods inherited from Redis::String
Methods inherited from Redis::Entity
#count, #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
#[](key) ⇒ Object
Quick access to the hash members for the value
47 48 49 |
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 47 def [](key) value[key.to_s] if value.is_a?(Hash) end |
#none? ⇒ Boolean
Check if this redis string is blank
26 27 28 |
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 26 def none? value.nil? || value.empty? end |
#present? ⇒ Boolean
Check if this redis string has a value
36 37 38 |
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 36 def present? !none? end |
#set(obj, pipeline = nil) ⇒ Hash
Writes the lock info to redis
58 59 60 61 62 63 64 65 66 |
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 58 def set(obj, pipeline = nil) return unless SidekiqUniqueJobs.config.lock_info raise InvalidArgument, "argument `obj` (#{obj}) needs to be a hash" unless obj.is_a?(Hash) json = dump_json(obj) @value = load_json(json) super(json, pipeline) value end |
#value ⇒ Hash
Returns the value for this key as a hash
16 17 18 |
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 16 def value @value ||= load_json(super) end |