Class: Cachy::RedisWrapper

Inherits:
Wrapper
  • Object
show all
Defined in:
lib/cachy/redis_wrapper.rb

Instance Method Summary collapse

Methods inherited from Wrapper

#initialize, #method_missing, #respond_to?

Constructor Details

This class inherits a constructor from Cachy::Wrapper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cachy::Wrapper

Instance Method Details

#delete(key) ⇒ Object



17
18
19
# File 'lib/cachy/redis_wrapper.rb', line 17

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

#read(key) ⇒ Object



5
6
7
8
9
# File 'lib/cachy/redis_wrapper.rb', line 5

def read(key)
  result = @wrapped[key]
  return if result.nil?
  YAML.load(result)
end

#write(key, value, options = {}) ⇒ Object



11
12
13
14
15
# File 'lib/cachy/redis_wrapper.rb', line 11

def write(key, value, options={})
  result = @wrapped.set(key, value.to_yaml)
  @wrapped.expire(key, options[:expires_in].to_i) if options[:expires_in]
  result
end