Sha256: ca23fb6af1b1588b6092ade37f522d064d94756f24392c441b4acd84e156127c

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

require 'redis'

module CurlyMustache
  module Adapters
    class Redis < Abstract
      
      def initialize(config)
        @redis = ::Redis.new(config)
      end
      
      def get(key)
        (data = @redis.get(key)) and Marshal.load(data)
      end
      
      def mget(keys)
        keys = keys.collect(&:to_s)
        @redis.mget(*keys).compact.collect{ |value| Marshal.load(value) }
      end
      
      def put(key, value)
        @redis.set(key, Marshal.dump(value))
      end
      
      def delete(key)
        @redis.delete(key)
      end
      
      def raw
        @redis
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cjbottaro-curly_mustache-0.0.0 lib/adapters/redis.rb