### Class Method: start Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html Starts the reaper resurrector process. ```APIDOC ## start ### Description Starts the reaper resurrector, which monitors the orphan reaper. This method initializes and begins the background process. ### Method `class` ### Returns - `SidekiqUniqueJobs::TimerTask` ``` -------------------------------- ### start Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Server.html Starts the Sidekiq unique jobs server process. This includes initiating version updates, upgrading locks, and starting orphan management processes. ```APIDOC ## start ### Description Start the sidekiq unique jobs server process. ### Method `self.start` ### Returns * void ``` -------------------------------- ### Run All Tests Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/CLAUDE.md Execute all tests in the project. Ensure you have all dependencies installed. ```bash bundle exec rspec ``` -------------------------------- ### Start Sidekiq Unique Jobs Server Process Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Server.html Initiates the Sidekiq unique jobs server process by calling various setup methods for version updates, lock upgrades, and orphan management. ```ruby def self.start [SidekiqUniqueJobs](../SidekiqUniqueJobs.html "SidekiqUniqueJobs (module)")::[UpdateVersion](UpdateVersion.html "SidekiqUniqueJobs::UpdateVersion (class)").[call](UpdateVersion.html#call-class_method "SidekiqUniqueJobs::UpdateVersion.call (method)") [SidekiqUniqueJobs](../SidekiqUniqueJobs.html "SidekiqUniqueJobs (module)")::[UpgradeLocks](UpgradeLocks.html "SidekiqUniqueJobs::UpgradeLocks (class)").[call](UpgradeLocks.html#call-class_method "SidekiqUniqueJobs::UpgradeLocks.call (method)") [SidekiqUniqueJobs](../SidekiqUniqueJobs.html "SidekiqUniqueJobs (module)")::[Orphans](Orphans.html "SidekiqUniqueJobs::Orphans (module)")::[Manager](Orphans/Manager.html "SidekiqUniqueJobs::Orphans::Manager (module)").[start](Orphans/Manager.html#start-class_method "SidekiqUniqueJobs::Orphans::Manager.start (method)") [SidekiqUniqueJobs](../SidekiqUniqueJobs.html "SidekiqUniqueJobs (module)")::[Orphans](Orphans.html "SidekiqUniqueJobs::Orphans (module)")::[ReaperResurrector](Orphans/ReaperResurrector.html "SidekiqUniqueJobs::Orphans::ReaperResurrector (module)").[start](Orphans/ReaperResurrector.html#start-class_method "SidekiqUniqueJobs::Orphans::ReaperResurrector.start (method)") end ``` -------------------------------- ### Install sidekiq-unique-jobs Gem Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/README.md Add this line to your Gemfile to install the gem. ```ruby gem "sidekiq-unique-jobs", "~> 9.0" ``` -------------------------------- ### Example Comparison Output Interpretation Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Interpret the comparison tool's output, which shows relative performance between branches for specific operations. This example highlights a significant improvement percentage. ```text lock with failure simulation: main: 1.234k i/s improved-exception-handling: 2.345k i/s <- ~90% improvement! ``` -------------------------------- ### Example IPS Output Interpretation Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Understand benchmark results presented as Iterations Per Second (IPS). Higher IPS values indicate better performance. This example shows how to compare the speed of different operations. ```text lock with failure simulation 1.234k i/s lock and unlock - normal flow 5.678k i/s ``` -------------------------------- ### Example Memory Usage Output Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Analyze memory allocation during benchmark operations. Lower allocated and retained memory values are preferable. This example shows memory usage for lock/unlock cycles. ```text 100 lock/unlock cycles allocated: 45.2 MB retained: 123 KB ``` -------------------------------- ### Quick Start: Compare Current Branch to Main Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Use the comparison tool for a quick verification of improvements in the current branch against the 'main' branch. This command runs benchmarks on both and displays key performance metrics. ```bash bin/compare_performance main improved-exception-handling ``` -------------------------------- ### Example: Unsatisfied Constraint Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Demonstrates an unsatisfied version constraint. Returns false when the version does not meet the constraint. ```ruby VersionCheck.satisfied?("5.0.0", "<= 4.0.0") #=> false ``` -------------------------------- ### Example: Satisfied Constraint Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Demonstrates a satisfied version constraint. Returns true when the version meets or exceeds the constraint. ```ruby VersionCheck.satisfied?("5.0.0", ">= 4.0.0") #=> true ``` -------------------------------- ### Example: Unfulfilled Constraint Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Demonstrates an unfulfilled version constraint. Returns true when the version does not meet the constraint. ```ruby VersionCheck.unfulfilled?("5.0.0", "<= 4.0.0") #=> true ``` -------------------------------- ### with_configured_loggers_context Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/UpgradeLocks.html Attempt to setup context aware logging for the given logger. ```APIDOC ## with_configured_loggers_context ### Description Attempt to setup context aware logging for the given logger. ### Yields This method yields a block for context-specific logging setup. ``` -------------------------------- ### with_configured_loggers_context Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Middleware.html Attempt to setup context aware logging for the given logger. ```APIDOC ## with_configured_loggers_context ### Description Attempt to setup context aware logging for the given logger. ### Method instance method ### Parameters #### Block - `{ ... }`: A block of code to execute within the context-aware logging setup. ``` -------------------------------- ### Get Configured Strategies Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict.html A convenience method for accessing the configured strategies within SidekiqUniqueJobs. ```ruby def self.strategies SidekiqUniqueJobs.strategies end ``` -------------------------------- ### Get Default Configuration Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Config.html Retrieves the default configuration object for SidekiqUniqueJobs. This is useful for inspecting or starting with a baseline configuration. ```ruby SidekiqUniqueJobs::Config.default ``` -------------------------------- ### Initialize Client with Configuration Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Client.html Initializes a new instance of the Client class, setting up configuration, logger, and fetching available scripts. ```ruby def initialize(config) @config = config @logger = config.logger @scripts = [Scripts].fetch(config.scripts_path) end ``` -------------------------------- ### Start Orphan Reaper Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Manager.html Starts a separate thread that periodically reaps orphans. Returns the timer task that was started. ```APIDOC ## .start(test_task = nil) ### Description Starts a separate thread that periodically reaps orphans. ### Parameters * **test_task** ([SidekiqUniqueJobs::TimerTask](../TimerTask.html "SidekiqUniqueJobs::TimerTask (class)")) - Optional - A task to use for testing. ### Returns * ([SidekiqUniqueJobs::TimerTask](../TimerTask.html "SidekiqUniqueJobs::TimerTask (class)")) - The timer task that was started. ``` -------------------------------- ### start Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html Starts the reaper resurrector task. This method checks if the reaper or resurrector is disabled before starting the task with logging context. ```APIDOC ## .start ### Description Starts reaper resurrector that watches orphans reaper. ### Returns * ([SidekiqUniqueJobs::TimerTask]) - The task that was started. ### Method Signature `start` ``` -------------------------------- ### Instance Method: initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock/BaseLock.html A new instance of BaseLock. ```APIDOC ## Instance Method: initialize ### Description A new instance of BaseLock. ### Method `initialize(item, callback, redis_pool = nil)` ### Parameters * **item** (Object) - The job item. * **callback** (Object) - The callback to execute. * **redis_pool** (Object) - Optional. The Redis pool to use. ``` -------------------------------- ### Instance Method: initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Initializes a new VersionCheck instance with a version string and a constraint string. ```APIDOC ## Instance Method: initialize(version, constraint) ### Description Initialize a new VersionCheck instance. ### Parameters * `version` (String) - a version string `5.0.0` * `constraint` (String) - a version constraint `>= 5.0.0 <= 5.1.1` ### Raises * (ArgumentError) - If version or constraint are missing. ``` -------------------------------- ### Initialize SidekiqUniqueJobs::RedisScript::Config Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Config.html Initializes a new instance of the Config class. Sets up Redis client, logger, and scripts path. ```ruby def initialize @conn = RedisClient.new @logger = Logger.new($stdout) @scripts_path = nil end ``` -------------------------------- ### Instance Method: initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Reaper.html Initializes a new instance of the Reaper class. It sets up the instance with a Redis connection. ```APIDOC ## initialize(conn) ### Description Initialize a new instance of DeleteOrphans. ### Parameters * `conn` (Object) - The Redis connection to use. ``` -------------------------------- ### Start Reaper Resurrector Task Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html Starts the orphan reaper task if it is not already disabled. It ensures logging context is set before running the task. ```ruby def start return if resurrector_disabled? return if reaper_disabled? with_logging_context do run_task end end ``` -------------------------------- ### Script#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Initializes a new Script instance with the given name and root path. It sets up instance variables for the script's name, path, source, SHA, and call count. ```APIDOC ## initialize(name:, root_path:) ### Description Initializes a new Script instance. ### Parameters - **name** (String) - The name of the script. - **root_path** (Pathname) - The root directory where the script is located. ### Returns - (Script) - A new instance of Script. ``` -------------------------------- ### Example: Satisfied Constraint (Unfulfilled Check) Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Demonstrates a satisfied version constraint when checking for unfulfillment. Returns false when the version meets the constraint. ```ruby VersionCheck.unfulfilled?("5.0.0", ">= 4.0.0") #=> false ``` -------------------------------- ### configure Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Server.html Configures the server middleware for SidekiqUniqueJobs. It sets up startup and shutdown hooks and adds a death handler. ```APIDOC ## configure(config) ### Description Configure the server middleware. ### Method `self.configure(config)` ### Parameters * **config** - The Sidekiq configuration object. ### Returns * The Sidekiq configuration object. ``` -------------------------------- ### SidekiqUniqueJobs::Config Instance Methods Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Config.html Documentation for the instance methods available on the SidekiqUniqueJobs::Config class. ```APIDOC ## Instance Method: `#add_lock` ### Description Adds a lock type to the configuration. ### Method `Instance` ### Signature `#add_lock(name, klass) ⇒ void` ``` ```APIDOC ## Instance Method: `#add_strategy` ### Description Adds an on_conflict strategy to the configuration. ### Method `Instance` ### Signature `#add_strategy(name, klass) ⇒ Object` ``` ```APIDOC ## Instance Method: `#class_name` ### Description Memoized variable to get the class name. ### Method `Instance` ### Signature `#class_name ⇒ String` ``` ```APIDOC ## Instance Method: `#redis_version` ### Description Returns the current version of Redis. ### Method `Instance` ### Signature `#redis_version ⇒ String` ``` -------------------------------- ### Get Script Name Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the name of the script. ```ruby def name @name end ``` -------------------------------- ### Initialize VersionCheck Instance Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Initializes a new VersionCheck instance with a version string and a constraint string. Raises ArgumentError if version or constraint are missing. ```ruby def initialize(version, constraint) @version = Gem::Version.new(version) @match = [PATTERN].match(constraint.to_s) raise ArgumentError, "A version (eg. 5.0) is required to compare against" unless @version raise ArgumentError, "At least one operator and version is required (eg. >= 5.1)" unless constraint end ``` -------------------------------- ### Get Script SHA Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the SHA hash of the script. ```ruby def sha @sha end ``` -------------------------------- ### Get Digests Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the digests associated with the Key instance. ```ruby def digests @digests end ``` -------------------------------- ### Template#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Template.html Constructor for the Template class. Initializes a new instance with the path to the script. ```APIDOC ## initialize(script_path) ### Description Returns a new instance of Template. ### Parameters * **script_path** (Object) - The path to the script. ### Returns * (Template) - A new instance of Template. ``` -------------------------------- ### Reflection API for Logging Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/file.README.html Set up the reflection API to capture insights like lock failures. This example shows how to log lock failures with job details. ```ruby def extract_log_from_job(message, job_hash) worker = job_hash['class'] args = job_hash['args'] lock_args = job_hash['lock_args'] queue = job_hash['queue'] { message: message, worker: worker, args: args, lock_args: lock_args, queue: queue } end SidekiqUniqueJobs.reflect do |on| on.lock_failed do |job_hash| message = extract_log_from_job('Lock Failed', job_hash) Sidekiq.logger.warn(message) end end ``` -------------------------------- ### Instance Methods Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Scripts.html Provides methods for initializing, managing, and executing scripts. ```APIDOC ## Instance Methods ### #**initialize**(path) Creates a new instance of Scripts. #### Parameters * `path` (Pathname) - the path to the scripts directory #### Raises * (ArgumentError) - if the path is not a Pathname object ### #**root_path** Returns the value of the `root_path` attribute. ### #**scripts** Returns the value of the `scripts` attribute. ### #**count** Returns the number of loaded scripts. ### #**delete**(script) Deletes a script from the collection. #### Parameters * `script` (Object) - the script to delete ### #**execute**(name, conn, keys: [], argv: []) Execute a lua script with the given name. #### Parameters * `name` (String) - the name of the script to execute * `conn` (Redis) - the Redis connection object * `keys` (Array) - an array of keys to pass to the script * `argv` (Array) - an array of arguments to pass to the script ### #**fetch**(name, conn) Fetches a script by its name from the Redis connection. #### Parameters * `name` (String) - the name of the script to fetch * `conn` (Redis) - the Redis connection object ### #**kill**(conn) Kills all running Lua scripts on the given Redis connection. #### Parameters * `conn` (Redis) - the Redis connection object ### #**load**(name, conn) Loads a Lua script with the given name into Redis. #### Parameters * `name` (String) - the name of the script to load * `conn` (Redis) - the Redis connection object ``` -------------------------------- ### Get Changelog Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the changelog associated with the Key instance. ```ruby def changelog @changelog end ``` -------------------------------- ### Configure Server Middleware Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Server.html Configures the server middleware by setting up startup and shutdown hooks, and adding a death handler. ```ruby def self.configure(config) config.on(:startup) { start } config.on(:shutdown) { stop } return unless config.respond_to?(:death_handlers) config.death_handlers << death_handler end ``` -------------------------------- ### Instance Method: initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock/BaseLock.html Initializes a new instance of BaseLock, setting up the necessary instance variables for job processing and configuration. ```APIDOC ## #initialize(item, callback, redis_pool = nil) ### Description Returns a new instance of BaseLock. ### Parameters * **item** (Hash) - Required - the Sidekiq job hash * **callback** (Proc) - Required - the callback to use after unlock * **redis_pool** (Sidekiq::RedisConnection, ConnectionPool) - Optional - the redis connection ### Method `initialize` ``` -------------------------------- ### Get Logger Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs.html Retrieves the logger instance currently used by SidekiqUniqueJobs. ```APIDOC ## .logger ### Description Returns the current logger. ### Returns * (Logger) - The configured logger. ``` -------------------------------- ### Configure Sidekiq Client and Server Middleware Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/README.md Configure Sidekiq to use the client and server middleware for unique job processing. This setup is typically placed in an initializer file. ```ruby # config/initializers/sidekiq.rb Sidekiq.configure_client do |config| config.client_middleware do |chain| chain.add SidekiqUniqueJobs::Middleware::Client end end Sidekiq.configure_server do |config| config.client_middleware do |chain| chain.add SidekiqUniqueJobs::Middleware::Client end config.server_middleware do |chain| chain.add SidekiqUniqueJobs::Middleware::Server end SidekiqUniqueJobs::Server.configure(config) end ``` -------------------------------- ### Strategy#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict/Strategy.html Initializes a new Strategy instance with a Sidekiq job hash and an optional Redis connection pool. ```APIDOC ## Strategy#initialize(item, redis_pool = nil) ### Description Initialize a new Strategy ### Parameters * **item** (Hash) - Required - sidekiq job hash * **redis_pool** (ConnectionPool) - Optional - the connection pool instance ### Method Signature ```ruby def initialize(item, redis_pool = nil) @item = item @redis_pool = redis_pool end ``` ``` -------------------------------- ### Get Locks Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs.html Retrieves a hash of all configured locks within SidekiqUniqueJobs. ```APIDOC ## .locks ### Description Returns the current locks. ### Returns * ([Hash]) - The configured locks. ``` -------------------------------- ### #configure Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html Configures the gem, typically called once at application startup. Accepts options or a block for configuration. ```APIDOC ## configure ### Description Configure the gem. This is usually called once at startup of an application ### Parameters * options ([Hash]) _(defaults to: {}) global gem options ### Options Hash * :path (String, Pathname) * :logger (Logger) — default: default is Logger.new(STDOUT) ### Yields * control to the caller when given block ``` -------------------------------- ### Get Script Path Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the file path to the script on disk. ```ruby def path @path end ``` -------------------------------- ### Run Comprehensive Benchmarks with bin/benchmark Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Execute the full suite of benchmarks to test all aspects of the gem, including lock acquisition, contention, digest generation, and memory usage. No specific setup is required beyond having the script available. ```bash bin/benchmark ``` -------------------------------- ### Get Info Key Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the suffixed key for the 'INFO' state. ```ruby def info @info end ``` -------------------------------- ### Get Locked Key Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the suffixed key for the 'LOCKED' state. ```ruby def locked @locked end ``` -------------------------------- ### Get Lock Configuration Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock/Validator.html Returns the initialized lock configuration object. ```ruby def lock_config @lock_config end ``` -------------------------------- ### Get Primed Key Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the suffixed key for the 'PRIMED' state. ```ruby def primed @primed end ``` -------------------------------- ### Strategy Initialization Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict/Strategy.html Initializes a new Strategy instance with an item and an optional Redis pool. ```APIDOC ## initialize(item, redis_pool = nil) ### Description Initializes a new Strategy. ### Parameters - **item**: The item associated with the strategy. - **redis_pool** (optional): The Redis pool to use. Defaults to nil. ``` -------------------------------- ### Console Method for CLI Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Cli.html Provides instructions to the user on how to use the `list` and `del` commands for managing unique job digests. It then starts the Thor console. ```ruby def console say "Use `list '*' 1000 to display the first 1000 unique digests matching '*'" say "Use `del '*' 1000, true (default) to see how many digests would be deleted for the pattern '*'" say "Use `del '*' 1000, false to delete the first 1000 digests matching '*'" # Object.include SidekiqUniqueJobs::Api console_class.start end ``` -------------------------------- ### initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html Initializes a new instance of RubyReaper with a Redis connection. ```APIDOC ## initialize(conn) ### Description Initializes a new instance of DeleteOrphans with a Redis connection. ### Parameters * **conn** ([Redis](../Redis.html "SidekiqUniqueJobs::Redis (module)")) - A connection to redis. ``` -------------------------------- ### Get Queued Key Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the suffixed key for the 'QUEUED' state. ```ruby def queued @queued end ``` -------------------------------- ### Initialize SidekiqUniqueJobs::RedisScript::Script Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Initializes a new instance of the Script class with the given name and root path. It sets up instance variables for the script's name, path, source, SHA, and call count. ```ruby def initialize(name:, root_path:) @name = name @root_path = root_path @path = root_path.join("#{name}.lua").to_s @source = render_file @sha = compiled_sha @call_count = 0 end ``` -------------------------------- ### Get Key Digest Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Returns the digest associated with this Key instance. ```ruby def digest @digest end ``` -------------------------------- ### initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict/Reschedule.html Initializes a new instance of the Reschedule strategy. ```APIDOC ## initialize ### Description Initializes a new instance of the Reschedule strategy. ### Method This is a constructor method. ### Parameters * **item** (Object) - Required - The job item to process. * **redis_pool** (Object, optional) - The Redis connection pool to use. ### Request Example ```ruby reschedule_instance = SidekiqUniqueJobs::OnConflict::Reschedule.new(job_item, redis_connection_pool) ``` ### Response Returns a new instance of `SidekiqUniqueJobs::OnConflict::Reschedule`. ``` -------------------------------- ### run_task Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html Executes the reaper resurrector task, logging the start and then executing the task. ```APIDOC ## .**run_task** ⇒ [SidekiqUniqueJobs::TimerTask](../TimerTask.html "SidekiqUniqueJobs::TimerTask (class)") Runs reaper resurrector task Returns: * ([SidekiqUniqueJobs::TimerTask](../TimerTask.html "SidekiqUniqueJobs::TimerTask (class)")) ```ruby def run_task log_info("Starting Reaper Resurrector") task.execute task end ``` ``` -------------------------------- ### Instance Method: #render_file Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Renders the script content by processing a template file. ```APIDOC ## #render_file ### Description Renders the script content by creating a new `Template` instance, passing it the `root_path`, and then calling its `render` method with the script's `path`. ### Returns - `Object`: The rendered script content. ``` -------------------------------- ### Get Script Root Path Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the root path where the script is located. ```ruby def root_path @root_path end ``` -------------------------------- ### Instance Method: execute Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock/BaseLock.html Execute the job in the Sidekiq server processor. ```APIDOC ## Instance Method: execute ### Description Execute the job in the Sidekiq server processor. ### Method `execute` ``` -------------------------------- ### Get Timer Task Options Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Manager.html Retrieves the options passed to the timer task. ```APIDOC ## .timer_task_options ### Description Returns arguments passed on to the timer task. ### Returns * ([Hash](../../Hash.html "Hash (class)")) - A hash of options for the timer task. ``` -------------------------------- ### Instance Method: prepare Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Job.html Adds timeout, expiration, lock_args, lock_prefix, and lock_digest to the Sidekiq job hash. ```APIDOC ## #prepare(item) ### Description Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash. ### Method Instance Method ### Parameters #### Path Parameters - **item** (Hash) - Description not available ### Returns - **Hash** - the job hash ``` -------------------------------- ### Get Timer Task Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Manager.html Retrieves the timer task used for reaping orphans. ```APIDOC ## .task ### Description Returns the task that runs the reaper. ### Returns * () - The current timer task. ``` -------------------------------- ### Get Primed JIDs Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Retrieves all job IDs currently in the primed list. ```ruby def primed_jids primed.entries end ``` -------------------------------- ### SidekiqUniqueJobs::Key#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Initializes a new Key object with a given digest. It sets up various suffixed keys for different job states like queued, primed, locked, and info. ```APIDOC ## initialize(digest) ### Description Initialize a new Key. ### Parameters * **digest** (String) - the digest to use as key ``` -------------------------------- ### Get Scheduled Time Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/LockTTL.html Retrieves the exact Unix time a job is scheduled at. ```ruby def scheduled_at @scheduled_at ||= item[SidekiqUniqueJobs::AT] end ``` -------------------------------- ### Manual Benchmark Comparison Workflow Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md Manually run benchmarks on different branches and compare the results using standard command-line tools. This involves checking out branches, redirecting benchmark output to files, and using 'diff' for comparison. ```bash # Save current branch name CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) # Benchmark main branch git checkout main bin/benchmark_improvements > results_main.txt # Benchmark your branch git checkout $CURRENT_BRANCH bin/benchmark_improvements > results_current.txt # Compare results diff -y results_main.txt results_current.txt | less ``` -------------------------------- ### Get Script File Path Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the full path to the script file on disk. ```ruby attr_reader :path ``` -------------------------------- ### UpgradeLocks#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/UpgradeLocks.html Initializes a new instance of the UpgradeLocks class. ```APIDOC ## UpgradeLocks#initialize ### Description Returns a new instance of UpgradeLocks. ### Method `initialize(conn)` ### Parameters * `conn` - The connection object to be used. ``` -------------------------------- ### Get Queued Job IDs Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Retrieves an array of queued job IDs from Redis. ```ruby def queued_jids queued.entries end ``` -------------------------------- ### Get Script Call Count Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the current value of the call_count attribute for the script. ```ruby def call_count @call_count end ``` -------------------------------- ### Verify Sigstore Attestation Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/RELEASING.md Use the `sigstore-cli` to verify the Sigstore attestation bundle for a release. This confirms the gem's authenticity and integrity. ```bash gem exec sigstore-cli verify-bundle \ --bundle sidekiq-unique-jobs-X.Y.Z.gem.sigstore.json \ --certificate-identity "https://github.com/mhenrixon/sidekiq-unique-jobs/.github/workflows/release.yml@refs/tags/vX.Y.Z" \ --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \ sidekiq-unique-jobs-X.Y.Z.gem ``` -------------------------------- ### Instance Method: #load Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Loads the script's source into Redis and stores its SHA1 digest. Handles connections with and without namespaces. ```APIDOC ## #load(conn) ### Description Loads the script's source into Redis using the `SCRIPT LOAD` command and stores the resulting SHA1 digest. It intelligently handles Redis connections that may or may not have a namespace defined. ### Parameters - `conn` (Redis Connection): The Redis connection object. ### Returns - `self` (Script): Returns the script instance itself after loading. ``` -------------------------------- ### Get Configured Logger Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Observer.html Provides a convenience method to access the configured gem logger. ```ruby logger ``` -------------------------------- ### SidekiqUniqueJobs::BatchDelete#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/BatchDelete.html Initialize a new batch delete instance. ```APIDOC ## initialize(digests, conn) ### Description Initialize a new batch delete instance. ### Parameters #### Path Parameters - **digests** (Object) - Required - The digests to be deleted. - **conn** (Object) - Required - The Redis connection. ### Method Constructor ``` -------------------------------- ### Get Current Time as Float Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Timing.html Returns the current time as a float. This method delegates to `SidekiqUniqueJobs.now_f`. ```ruby def now_f [SidekiqUniqueJobs.now_f] end ``` -------------------------------- ### Initialize Template for Redis Script Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Template.html Constructor for the Template class. Initializes the template with the path to the main script file. ```ruby def initialize(script_path) @script_path = script_path end ``` -------------------------------- ### Get Script Name Without Extension Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the name of the script without its file extension. ```ruby attr_reader :name ``` -------------------------------- ### Get Configured Logger Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Logging.html Returns the logger instance configured for the gem. This method is a convenience wrapper. ```ruby def logger [SidekiqUniqueJobs](../../SidekiqUniqueJobs.html "SidekiqUniqueJobs (module)")::[RedisScript](../RedisScript.html "SidekiqUniqueJobs::RedisScript (module)").[logger](../RedisScript.html#logger-class_method "SidekiqUniqueJobs::RedisScript.logger (method)") end ``` -------------------------------- ### Reaper#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Reaper.html Initializes a new instance of the Reaper class with a provided Redis connection. ```APIDOC ## #initialize(conn) ⇒ Reaper ### Description Initialize a new instance of DeleteOrphans ### Method `initialize` ### Parameters #### Path Parameters - **conn** (Redis) - Required. A connection to Redis. ### Returns - `Reaper` - A new instance of the Reaper class. ``` -------------------------------- ### Get Reaper Timeout Setting Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Reaper.html Retrieves the configured timeout in seconds for the orphan reaper process. ```ruby def reaper_timeout config.reaper_timeout end ``` -------------------------------- ### Initialize Sidekiq::Deadset Instance Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict/Reject.html This private method initializes and returns an instance of `Sidekiq::Deadset`. It uses memoization to ensure only one instance is created. ```ruby def deadset @deadset ||= ::Sidekiq::DeadSet.new end ``` -------------------------------- ### Initialize SidekiqUniqueJobs::Key Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Key.html Initializes a new Key instance with a given digest and generates suffixed keys for various states like QUEUED, PRIMED, LOCKED, and INFO. It also sets changelog and digests attributes. ```ruby def initialize(digest) @digest = digest @queued = suffixed_key("QUEUED") @primed = suffixed_key("PRIMED") @locked = suffixed_key("LOCKED") @info = suffixed_key("INFO") @changelog = [SidekiqUniqueJobs::CHANGELOGS](../SidekiqUniqueJobs.html#CHANGELOGS-constant "SidekiqUniqueJobs::CHANGELOGS (constant)") @digests = [SidekiqUniqueJobs::DIGESTS](../SidekiqUniqueJobs.html#DIGESTS-constant "SidekiqUniqueJobs::DIGESTS (constant)") end ``` -------------------------------- ### Get Configured Reaper Type Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Reaper.html Retrieves the symbol representing the configured orphan reaper strategy. ```ruby def reaper config.reaper end ``` -------------------------------- ### Get a members value Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Redis/Hash.html Retrieves the value associated with a specific member within the Redis hash. ```APIDOC ## [] ### Description Get a members value. ### Method `[]` ### Parameters #### Path Parameters - **member** (String) - Required - The member whose value to get. ### Returns - Object - Whatever is stored on this hash member. ``` -------------------------------- ### Locksmith#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Locksmith.html Initializes a new Locksmith instance with the given item and an optional Redis pool. ```APIDOC ## initialize(item, redis_pool = nil) ### Description Initialize a new Locksmith instance. ### Parameters - **item**: The item to associate with the lock. - **redis_pool**: Optional Redis connection pool. ``` -------------------------------- ### Get Logging Context Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Observer.html Sets up variables to be included in each log line. Raises NotImplementedError if not implemented. ```ruby logging_context ``` -------------------------------- ### Instance Method: #source Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Script.html Returns the raw Lua source code of the Redis script. ```APIDOC ## #source ### Description Returns the string containing the Lua source code for this Redis script. ### Returns - `Object`: The source code of the script. ``` -------------------------------- ### Get Current Timestamp Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/ReaperResurrector.html Returns the current time as an integer timestamp. Used for time-based comparisons. ```ruby def current_timestamp Time.now.to_i end ``` -------------------------------- ### Run All Style Checks Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/CLAUDE.md Execute all configured style checks for the project. This is a comprehensive check for code quality. ```bash bundle exec rake style ``` -------------------------------- ### #initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Reflections.html Initializes a new instance of the Reflections class. It sets up an internal hash to store registered reflection callbacks. ```APIDOC ## #initialize ⇒ Reflections Returns a new instance of Reflections. ### Method `initialize` ### Description Creates a new instance of the `Reflections` class, initializing an empty hash to store reflection callbacks. ### Returns * (Reflections) - A new instance of the `Reflections` class. ``` -------------------------------- ### Get Lock Class Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OptionsWithFallback.html Returns the corresponding class for the lock_type. Raises UnknownLock if the lock_type is not found. ```ruby def lock_class @lock_class ||= locks.fetch(lock_type.to_sym) do raise [UnknownLock](UnknownLock.html "SidekiqUniqueJobs::UnknownLock (class)"), "No implementation for `lock: :#{lock_type}`" end end ``` -------------------------------- ### initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock/WhileExecuting.html Initializes a new instance of the WhileExecuting lock strategy. ```APIDOC ## initialize(item, callback, redis_pool = nil) ### Description Returns a new instance of WhileExecuting. ### Parameters * **item** (Hash) - the Sidekiq job hash * **callback** (Proc) - callback to call after unlock * **redis_pool** (Sidekiq::RedisConnection, ConnectionPool) - the redis connection (defaults to nil) ``` -------------------------------- ### Get Class Name Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Config.html Retrieves the memoized class name. This is useful for logging or internal referencing. ```ruby class_name ``` -------------------------------- ### Class Method: prepare Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Job.html Adds timeout, expiration, lock_args, lock_prefix, and lock_digest to the Sidekiq job hash. ```APIDOC ## .prepare(item) ### Description Adds timeout, expiration, lock_args, lock_prefix and lock_digest to the sidekiq job hash. ### Method Class Method ### Parameters #### Path Parameters - **item** (Hash) - Description not available ### Returns - **Hash** - the job hash ``` -------------------------------- ### Generate Documentation Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/CLAUDE.md Generate project documentation using YARD. This command is typically used by maintainers. ```bash bundle exec rake yard ``` -------------------------------- ### Get Reaper Batch Count Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/Reaper.html Retrieves the integer value for the number of locks to be reaped in a single batch. ```ruby def reaper_count config.reaper_count end ``` -------------------------------- ### Instance Method: initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Initializes a new lock instance with a key and an optional timestamp. ```APIDOC ## Instance Method: initialize ### Description Initialize a new lock. ### Signature ```ruby initialize(key, time: nil) ⇒ Lock ``` ### Parameters * **key** (Object) - The key for the lock. * **time** (Object) - Optional timestamp for the lock. ``` -------------------------------- ### Get Logger Instance Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/Config.html Returns the configured logger instance. This attribute is used for logging within the gem. ```ruby def logger @logger end ``` -------------------------------- ### CI/CD Integration for Benchmarks Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/BENCHMARKING.md This YAML configuration sets up a GitHub Actions workflow to run benchmarks on pull requests against the main branch. It includes setting up Ruby, caching dependencies, and running benchmark comparison scripts. ```yaml # .github/workflows/benchmark.yml name: Performance Benchmarks on: pull_request: branches: [main] jobs: benchmark: runs-on: ubuntu-latest services: redis: image: redis:7 ports: - 6379:6379 steps: - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: 3.2 bundler-cache: true - name: Run benchmarks run: bin/benchmark_improvements - name: Compare with main run: | git fetch origin main bin/compare_performance origin/main HEAD ``` -------------------------------- ### Get Current Configuration Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html Retrieves the current configuration for the gem. It ensures thread-safe access to the configuration object. ```ruby def config [MUTEX](../DSL.html#MUTEX-constant "SidekiqUniqueJobs::RedisScript::DSL::MUTEX (constant)").synchronize do @config ||= [Config](../Config.html "SidekiqUniqueJobs::RedisScript::Config (class)").[new](../Config.html#initialize-instance_method "SidekiqUniqueJobs::RedisScript::Config#initialize (method)") end end ``` -------------------------------- ### Configuration Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs.html Methods for accessing and configuring SidekiqUniqueJobs. ```APIDOC ## .config ### Description Returns the current configuration object for SidekiqUniqueJobs. ### Method `SidekiqUniqueJobs.config` ## .configure(options = {}) { ... } ### Description Allows configuring the gem with various options. This method can be used to set up custom configurations. ### Method `SidekiqUniqueJobs.configure(options = {})` ## .reset! ### Description Resets the gem's configuration to its default settings. ### Method `SidekiqUniqueJobs.reset!` ## .use_config(tmp_config = {}) { ... } ### Description Temporarily applies a given configuration and reverts to the previous configuration after the block finishes execution. ### Method `SidekiqUniqueJobs.use_config(tmp_config = {})` ``` -------------------------------- ### Get Scheduled Attribute Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html Returns the internal sorted set object used for tracking scheduled jobs. ```ruby def scheduled @scheduled end ``` -------------------------------- ### Entity Initialization Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Redis/Entity.html Initializes a new Entity object with a given Redis key. ```APIDOC ## initialize(key) ### Description Initialize a new Entity ### Parameters * **key** (String) - the redis key for this entity ``` -------------------------------- ### Get Retried Attribute Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Orphans/RubyReaper.html Returns the internal sorted set object used for tracking retried jobs. ```ruby def retried @retried end ``` -------------------------------- ### default_lock_timeout Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Config.html Gets the default lock timeout value. This method is deprecated and users should use `lock_timeout` instead. ```APIDOC ## default_lock_timeout ### Description **Deprecated.** Default Lock Timeout. ### Returns * (nil, Integer) - configured value or nil ``` -------------------------------- ### Options Handling Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Middleware.html Methods for accessing and checking middleware options. ```APIDOC ## options ### Description The default options with any matching keys overridden from worker options. ### Returns * (Hash) - A hash containing the merged options. ``` ```APIDOC ## unique_disabled? ### Description Check if unique job functionality has been disabled. ### Returns * (Boolean) - True if unique jobs are disabled, false otherwise. ``` ```APIDOC ## unique_enabled? ### Description Check if unique job functionality has been enabled. ### Returns * (true, false) - True if unique jobs are enabled, false otherwise. ``` -------------------------------- ### Get Redis Version Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Config.html Fetches and returns the current Redis version. It caches the version after the first retrieval. ```ruby redis_version ``` -------------------------------- ### Instance Method: satisfied? Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/VersionCheck.html Checks if the constraints provided during initialization are met by the instance's version. ```APIDOC ## Instance Method: satisfied? ### Description Checks if all constraints were met. ### Returns * (true, false) ``` -------------------------------- ### Get Item Attribute Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/LockTimeout.html Returns the stored Sidekiq job hash for the LockTimeout instance. This attribute is read-only. ```ruby def item @item end ``` -------------------------------- ### Configure Sidekiq Unique Jobs Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/file.README.html Configure the global settings for sidekiq-unique-jobs. This example disables the gem in test environments. ```ruby SidekiqUniqueJobs.configure do |config| config.enabled = !Rails.env.test? end ``` -------------------------------- ### #execute Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/RedisScript/DSL/ClassMethods.html Executes a Redis script using the provided connection, keys, and arguments. ```APIDOC ## execute ### Description Executes a Redis script. ### Parameters * file_name (String) * conn (Redis connection object) * keys (Array) _(defaults to: [])_ * argv (Array) _(defaults to: [])_ ``` -------------------------------- ### Run All Checks Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/CLAUDE.md Perform a complete check of the project, including style, tests, and documentation. This is often run before merging or releasing. ```bash bundle exec rake ``` -------------------------------- ### SidekiqUniqueJobs::LockConfig#initialize Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/LockConfig.html Initializes a new instance of LockConfig with optional job hash. ```APIDOC ## SidekiqUniqueJobs::LockConfig#initialize(job_hash = {}) ### Description A new instance of LockConfig. ### Method `initialize` (constructor) ### Parameters #### Path Parameters - **job_hash** (Object) - Optional - Defaults to {} Description not available ``` -------------------------------- ### Get Time Source as Integer Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Timing.html Provides a callable time source that returns the current time as an integer (milliseconds). ```ruby def time_source -> { (clock_stamp * 1000).to_i } end ``` -------------------------------- ### Get Primed List Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Returns a Redis::List object representing the primed jobs. This is initialized on first access. ```ruby def primed @primed ||= [Redis](Redis.html "SidekiqUniqueJobs::Redis (module)")::[List](Redis/List.html "SidekiqUniqueJobs::Redis::List (class)").[new](Redis/Entity.html#initialize-instance_method "SidekiqUniqueJobs::Redis::Entity#initialize (method)")(key.primed) end ``` -------------------------------- ### Get Locked JIDs Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Retrieves a collection of locked job IDs. Optionally includes timestamps if `with_values` is true. ```ruby def locked_jids(with_values: false) locked.entries(with_values: with_values) end ``` -------------------------------- ### Get Locked Hash Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Lock.html Returns a Redis::Hash object representing the locked jobs. This is initialized on first access. ```ruby def locked @locked ||= [Redis](Redis.html "SidekiqUniqueJobs::Redis (module)")::[Hash](Redis/Hash.html "SidekiqUniqueJobs::Redis::Hash (class)").[new](Redis/Entity.html#initialize-instance_method "SidekiqUniqueJobs::Redis::Entity#initialize (method)")(key.locked) end ``` -------------------------------- ### Initialize Strategy Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/OnConflict/Strategy.html Initializes a new Strategy instance with the given Sidekiq job hash and an optional Redis connection pool. ```ruby def initialize(item, redis_pool = nil) @item = item @redis_pool = redis_pool end ``` -------------------------------- ### Get All Entries from Set Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Redis/Set.html Returns all entries currently stored in the Redis set. This method utilizes the `smembers` command. ```ruby def entries redis { |conn| conn.smembers(key) } end ``` -------------------------------- ### Get Count of Set Entries Source: https://github.com/mhenrixon/sidekiq-unique-jobs/blob/main/doc/SidekiqUniqueJobs/Redis/Set.html Returns the number of entries in the Redis set. This method uses the `scard` command. ```ruby def count redis { |conn| conn.scard(key) } end ```