Class: SidekiqUniqueJobs::LockInfo

Inherits:
Redis::String show all
Defined in:
lib/sidekiq_unique_jobs/lock_info.rb

Overview

Class Info provides information about a lock

Author:

Instance Attribute Summary

Attributes inherited from Redis::Entity

#key

Instance Method Summary collapse

Methods inherited from Redis::String

#count, #del

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, 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

Parameters:

  • key (String, Symbol)

    the key who’s value to retrieve

Returns:

  • (Object)


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

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


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

Parameters:

  • obj (Hash)

    the information to store at key

Returns:

Raises:



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

#valueHash

Returns the value for this key as a hash

Returns:



16
17
18
# File 'lib/sidekiq_unique_jobs/lock_info.rb', line 16

def value
  @value ||= load_json(super)
end