Class: RedisKit::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/redis-kit/cache.rb,
lib/redis-kit/cache/helper.rb

Defined Under Namespace

Modules: Helper

Class Method Summary collapse

Class Method Details

.expire(key) ⇒ Object



15
16
17
# File 'lib/redis-kit/cache.rb', line 15

def expire( key )
  RedisKit.del key
end

.get(key, timeout, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/redis-kit/cache.rb', line 4

def get( key, timeout, &block )
  key = key.to_s
  if value = RedisKit.redis.get( key )
    value
  else
    value = yield
    RedisKit.redis.setex key, timeout, value
    value
  end
end