Class: Wework::JsTicket::RedisStore
- Defined in:
- lib/wework/js_ticket/redis_store.rb
Instance Attribute Summary
Attributes inherited from Store
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(agent) ⇒ RedisStore
constructor
A new instance of RedisStore.
- #jsapi_ticket ⇒ Object
- #refresh_token ⇒ Object
Constructor Details
#initialize(agent) ⇒ RedisStore
Returns a new instance of RedisStore.
5 6 7 8 |
# File 'lib/wework/js_ticket/redis_store.rb', line 5 def initialize(agent) raise RedisNotConfigException if redis.nil? super end |
Instance Method Details
#expired? ⇒ Boolean
15 16 17 |
# File 'lib/wework/js_ticket/redis_store.rb', line 15 def expired? redis.hvals(key).empty? || redis.hget(key, "expires_at").to_i <= Time.now.to_i end |
#jsapi_ticket ⇒ Object
10 11 12 13 |
# File 'lib/wework/js_ticket/redis_store.rb', line 10 def jsapi_ticket super redis.hget(key, "ticket") end |
#refresh_token ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/wework/js_ticket/redis_store.rb', line 19 def refresh_token result = super if result.success? expires_at = Time.now.to_i + result.expires_in.to_i - Wework.expired_shift_seconds redis.hmset( key, "ticket", result.ticket, "expires_at", expires_at ) redis.expireat(key, expires_at) end end |