Class: ThirdPartyWxa::Token::RedisStore
- Inherits:
-
Store
- Object
- Store
- ThirdPartyWxa::Token::RedisStore
show all
- Defined in:
- lib/third_party_wxa/token/redis_store.rb
Instance Attribute Summary
Attributes inherited from Store
#plugin
Instance Method Summary
collapse
Methods inherited from Store
init_with, #initialize
Instance Method Details
#get_token ⇒ Object
19
20
21
|
# File 'lib/third_party_wxa/token/redis_store.rb', line 19
def get_token
wx_redis.hget(plugin.redis_key, 'component_access_token')
end
|
#set_token ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/third_party_wxa/token/redis_store.rb', line 11
def set_token
res = plugin.component_access_token_api
wx_redis.hmset plugin.redis_key,
'component_access_token', res['component_access_token'],
'component_expire_at', ThirdPartyWxa.cal_expire_at(res['expires_in'])
plugin
end
|
#valid? ⇒ Boolean
6
7
8
9
|
# File 'lib/third_party_wxa/token/redis_store.rb', line 6
def valid?
return false if wx_redis.hget(plugin.redis_key, 'component_access_token').blank?
Time.now.to_i <= wx_redis.hget(plugin.redis_key, 'component_expire_at').to_i
end
|
#wx_redis ⇒ Object
23
24
25
|
# File 'lib/third_party_wxa/token/redis_store.rb', line 23
def wx_redis
ThirdPartyWxa.wx_redis
end
|