Sha256: 5e79876ae72076b9473862479ab201ccd4fb22ca266d9e91fef8f6982ba6aa6f

Contents?: true

Size: 1.02 KB

Versions: 31

Compression:

Stored size: 1.02 KB

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, pipeline = nil)
        return pipeline.set(key, obj) if pipeline

        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

31 entries across 31 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-8.0.10 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.33 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.32 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.9 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.8 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.7 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.6 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.31 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.5 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.4 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.30 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.3 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.2 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.1 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-8.0.0 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.29 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.28 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.27 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.26 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.1.25 lib/sidekiq_unique_jobs/redis/string.rb