Class: SidekiqUniqueJobs::Redis::String

Inherits:
Entity
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/redis/string.rb

Overview

Class String provides convenient access to redis strings

Author:

Direct Known Subclasses

LockInfo

Instance Attribute Summary

Attributes inherited from Entity

#key

Instance Method Summary collapse

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

#count1, 0

Used only for compatibility with other keys

Returns:

  • (1)

    when key exists

  • (0)

    when key does not exists



46
47
48
# File 'lib/sidekiq_unique_jobs/redis/string.rb', line 46

def count
  exist? ? 1 : 0
end

#delObject

Removes the key from redis



37
38
39
# File 'lib/sidekiq_unique_jobs/redis/string.rb', line 37

def del(*)
  redis { |conn| conn.del(key) }
end

#set(obj, pipeline = nil) ⇒ true, false

Sets the value of the key to given object

Parameters:

  • obj (String)

    the object to update the key with

Returns:

  • (true, false)


28
29
30
31
32
# File 'lib/sidekiq_unique_jobs/redis/string.rb', line 28

def set(obj, pipeline = nil)
  return pipeline.set(key, obj) if pipeline

  redis { |conn| conn.set(key, obj) }
end

#valueString

Returns the value of the key

Returns:



17
18
19
# File 'lib/sidekiq_unique_jobs/redis/string.rb', line 17

def value
  redis { |conn| conn.get(key) }
end