Class: JWTea::Stores::RedisStore

Inherits:
Object
  • Object
show all
Defined in:
lib/jwtea/stores/redis_store.rb

Constant Summary collapse

OK =
'OK'

Instance Method Summary collapse

Constructor Details

#initialize(*redis_options) ⇒ RedisStore

Returns a new instance of RedisStore.



9
10
11
# File 'lib/jwtea/stores/redis_store.rb', line 9

def initialize(*redis_options)
  @redis = ::Redis.new(*redis_options)
end

Instance Method Details

#delete(key) ⇒ Object



22
23
24
25
# File 'lib/jwtea/stores/redis_store.rb', line 22

def delete(key)
  result = @redis.del(key)
  result == 1
end

#exists?(key, value) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/jwtea/stores/redis_store.rb', line 18

def exists?(key, value)
  @redis.get(key) == value.to_s
end

#save(key, value, ttl_in_seconds) ⇒ Object



13
14
15
16
# File 'lib/jwtea/stores/redis_store.rb', line 13

def save(key, value, ttl_in_seconds)
  result = @redis.setex(key, ttl_in_seconds, value.to_s)
  result == OK
end