Class: Haoyaoshi::Token::RedisStore
- Inherits:
-
Store
- Object
- Store
- Haoyaoshi::Token::RedisStore
show all
- Defined in:
- lib/haoyaoshi/token/redis_store.rb
Instance Attribute Summary
Attributes inherited from Store
#client
Instance Method Summary
collapse
Methods inherited from Store
#authenticate, #authenticate_headers, #http_get_access_token, init_with, #initialize, #set_access_token
Instance Method Details
#access_token ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/haoyaoshi/token/redis_store.rb', line 27
def access_token
super
client.access_token = haoyaoshi_redis.hget(client.redis_key, "access_token")
client.expired_at = haoyaoshi_redis.hget(client.redis_key, "expired_at")
client.token_type = haoyaoshi_redis.hget(client.redis_key, "token_type")
client.access_token
end
|
#haoyaoshi_redis ⇒ Object
#refresh_token ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/haoyaoshi/token/redis_store.rb', line 15
def refresh_token
super
haoyaoshi_redis.hmset(
client.redis_key, "access_token",
client.access_token, "expired_at",
client.expired_at, "token_type",
client.token_type
)
haoyaoshi_redis.expireat(client.redis_key, client.expired_at.to_i)
end
|
#token_expired? ⇒ Boolean
11
12
13
|
# File 'lib/haoyaoshi/token/redis_store.rb', line 11
def token_expired?
haoyaoshi_redis.hvals(client.redis_key).empty?
end
|
#valid? ⇒ Boolean
6
7
8
9
|
# File 'lib/haoyaoshi/token/redis_store.rb', line 6
def valid?
haoyaoshi_redis.del(client.redis_key)
super
end
|