Sha256: e9acea0515ffbe3d7f548c7f82fe6abeb22ba6e69fc30a1b0dee69a705cfc3de

Contents?: true

Size: 766 Bytes

Versions: 5

Compression:

Stored size: 766 Bytes

Contents

begin
  require 'redis'
rescue LoadError
  raise "You must install redis to use the Redis cache store backend"
end

module Padrino
  module Cache
    module Store
      class Redis
        def initialize(*args)
          @backend = ::Redis.new(*args)
        end

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

        def set(key, value, opts = nil)
          if opts && opts[:expires_in]
            expires_in = opts[:expires_in].to_i
            @backend.setex(key, expires_in, value)
          else
            @backend.set(key, value)
          end
        end

        def delete(key)
          @backend.del(key)
        end

        def flush
          @backend.flushdb
        end
      end # Redis
    end # Store
  end # Cache
end # Padrino

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
padrino-cache-0.9.24 lib/padrino-cache/store/redis.rb
padrino-cache-0.9.23 lib/padrino-cache/store/redis.rb
padrino-cache-0.9.22 lib/padrino-cache/store/redis.rb
padrino-cache-0.9.21 lib/padrino-cache/store/redis.rb
padrino-cache-0.9.20 lib/padrino-cache/store/redis.rb