Sha256: b1dd2b01641d9adf80ffa9781e314b25d0fce2041dc9ac856dfb7f076377b08b

Contents?: true

Size: 599 Bytes

Versions: 1

Compression:

Stored size: 599 Bytes

Contents

require 'redis'

module Legion
  module Cache
    module Redis
      def connect
        @client = ::Redis.new
      end

      def close
        @client.close
      end

      def restart
        close
        connect
      end

      def get(key)
        @client.get(key)
      end
      alias fetch get

      def set(key, value, ttl: nil)
        args = {}
        args[:ex] = ttl unless ttl.nil?
        @client.set(key, value, **args) == 'OK'
      end

      def delete(key)
        @client.del(key) == 1
      end

      def flush
        @client.flushdb == 'OK'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legion-cache-0.2.1 lib/legion/cache/redis.rb