Sha256: c370da4169f16a9557654912f5802172c84579fe69b934bca280726e98aed8a0

Contents?: true

Size: 975 Bytes

Versions: 24

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@zoolutions.se>
    #
    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

24 entries across 24 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-7.0.0.beta25 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta24 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta23 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta22 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta21 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta20 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta19 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta18 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta17 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta16 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta15 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta14 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta13 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta12 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta11 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta10 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta9 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta8 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta7 lib/sidekiq_unique_jobs/redis/string.rb
sidekiq-unique-jobs-7.0.0.beta6 lib/sidekiq_unique_jobs/redis/string.rb