Sha256: b94d841f477f24a08d75fa62679037957f441a41b565c850803fa320f14bfe37

Contents?: true

Size: 995 Bytes

Versions: 1

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

require "redis"

module CollectionSpace
  class RefCache
    module Backend
      class Redis
        def initialize(url)
          # https://devcenter.heroku.com/articles/heroku-redis#connecting-in-rails
          @c = ::Redis.new(url: url, ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE})
        end

        def clean
          # blank method; Redis handles removal of expired keys automagically, as per
          #  https://redis.io/commands/expire
        end

        def connected?
          @c.ping
        rescue
          false
        end

        def exists?(key)
          @c.exists?(key)
        end

        def flush
          @c.flushdb
        end

        def get(key)
          @c.get(key)
        end

        def put(key, value, lifetime: nil)
          @c.set(key, value, ex: lifetime)
        end

        def remove(key)
          @c.del(key)
        end

        def size
          @c.dbsize
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
collectionspace-refcache-1.0.0 lib/collectionspace/refcache/backend/redis.rb