Sha256: b136556766b25cfa75da7b96009500abc014e64e3c74c23a847a71a14b5caefe

Contents?: true

Size: 975 Bytes

Versions: 30

Compression:

Stored size: 975 Bytes

Contents

# frozen_string_literal: true

module SidekiqUniqueJobs
  module Redis
    #
    # Class String provides convenient access to redis strings
    #
    # @author Mikael Henriksson <mikael@mhenrixon.com>
    #
    class String < Entity
      #
      # Returns the value of the key
      #
      #
      # @return [String]
      #
      def value
        redis { |conn| conn.get(key) }
      end

      #
      # Sets the value of the key to given object
      #
      # @param [String] obj the object to update the key with
      #
      # @return [true, false]
      #
      def set(obj)
        redis { |conn| conn.set(key, obj) }
      end

      #
      # Removes the key from redis
      #
      def del(*)
        redis { |conn| conn.del(key) }
      end

      #
      # Used only for compatibility with other keys
      #
      # @return [1] when key exists
      # @return [0] when key does not exists
      def count
        exist? ? 1 : 0
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.1.13 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.12 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.11 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.10 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.8 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.13 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.7 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.6 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.5 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.3 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.2 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.1 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.0 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.12 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.11 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.10 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.9 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.8 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.7 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.6 lib/sidekiq_unique_jobs/redis/string.rb