Sha256: a55bcf4cb7a6d0d9026e639957312acbcccde02fceabde37b705a1d8d1abcf70

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

require 'thor'

module SidekiqUniqueJobs
  class Cli < Thor
    desc 'keys PATTERN', 'list all unique keys and their expiry time'
    option :count, aliases: :c, type: :numeric, default: 1000, desc: 'The max number of keys to return'
    def keys(pattern)
      Util.keys(pattern, options[:count])
    end

    desc 'del PATTERN', 'deletes unique keys from redis by pattern'
    option :dry_run, aliases: :d, type: :boolean, desc: 'set to false to perform deletion'
    option :count, aliases: :c, type: :numeric, default: 1000, desc: 'The max number of keys to return'
    def del(pattern)
      Util.del(pattern, options[:count], options[:dry_run])
    end

    desc 'console', 'drop into a console with easy access to helper methods'
    def console
      puts "Use `keys '*', 1000 to display the first 1000 unique keys matching '*'"
      puts "Use `del '*', 1000, true (default) to see how many keys would be deleted for the pattern '*'"
      puts "Use `del '*', 1000, false to delete the first 1000 keys matching '*'"
      Object.include SidekiqUniqueJobs::Util
      console_class.start
    end

    private

    def console_class
      require 'pry'
      Pry
    rescue LoadError
      require 'irb'
      IRB
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.0 lib/sidekiq_unique_jobs/cli.rb
sidekiq-unique-jobs-4.0.18 lib/sidekiq_unique_jobs/cli.rb