Class: Dingtalk::Token::RedisStore
- Inherits:
-
Store
- Object
- Store
- Dingtalk::Token::RedisStore
show all
- Defined in:
- lib/dingtalk/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
24
25
26
27
28
29
|
# File 'lib/dingtalk/token/redis_store.rb', line 24
def access_token
super
client.access_token = redis.hget(client.redis_key, "access_token")
client.expired_at = redis.hget(client.redis_key, "expired_at")
client.access_token
end
|
#redis ⇒ Object
31
32
33
|
# File 'lib/dingtalk/token/redis_store.rb', line 31
def redis
Dingtalk.redis
end
|
#refresh_token ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/dingtalk/token/redis_store.rb', line 14
def refresh_token
super
redis.hmset(
client.redis_key, "access_token",
client.access_token, "expired_at",
client.expired_at
)
redis.expireat(client.redis_key, client.expired_at.to_i)
end
|
#token_expired? ⇒ Boolean
10
11
12
|
# File 'lib/dingtalk/token/redis_store.rb', line 10
def token_expired?
redis.hvals(client.redis_key).empty?
end
|
#valid? ⇒ Boolean
5
6
7
8
|
# File 'lib/dingtalk/token/redis_store.rb', line 5
def valid?
redis.del(client.redis_key)
super
end
|