Sha256: 3370558717a70b17d0a7a018352890b96544eec2f1c22218a73d916eab467cc6

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

module AnyCache::Adapters
  # @api private
  # @since 0.1.0
  class RedisStore < Redis
    class << self
      # @param driver [Object]
      # @return [Boolean]
      #
      # @api private
      # @since 0.1.0
      def supported_driver?(driver)
        defined?(::Redis::Store) && driver.is_a?(::Redis::Store)
      end
    end

    # @param key [String]
    # @param options [Hash]
    # @return [Object]
    #
    # @api private
    # @since 0.1.0
    def read(key, **options)
      get(key, raw: true)
    end

    # @param key [String]
    # @param value [Object]
    # @option expires_in [NilClass, Integer] Time in seconds
    # @return [void]
    #
    # @api private
    # @since 0.1.0
    def write(key, value, **options)
      expires_in = options.fetch(:expires_in, NO_EXPIRATION_TTL)

      expires_in ? setex(key, expires_in, value, raw: true) : set(key, value, raw: true)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
any_cache-0.1.0 lib/any_cache/adapters/redis_store.rb