Class: WeixinAuthorize::JsTicket::RedisStore

Inherits:
Store
  • Object
show all
Defined in:
lib/weixin_authorize/js_ticket/redis_store.rb

Constant Summary collapse

JSTICKET =
"jsticket"
EXPIRED_AT =
"expired_at"

Instance Attribute Summary

Attributes inherited from Store

#client

Instance Method Summary collapse

Methods inherited from Store

init_with, #initialize, #set_jsticket

Constructor Details

This class inherits a constructor from WeixinAuthorize::JsTicket::Store

Instance Method Details

#jsticketObject



26
27
28
29
30
31
32
33
34
# File 'lib/weixin_authorize/js_ticket/redis_store.rb', line 26

def jsticket
  super
  client.jsticket = weixin_redis.hget(client.jsticket_redis_key, JSTICKET)
  client.jsticket_expired_at = weixin_redis.hget(
    client.jsticket_redis_key,
    EXPIRED_AT
  )
  client.jsticket
end

#jsticket_expired?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/weixin_authorize/js_ticket/redis_store.rb', line 7

def jsticket_expired?
  weixin_redis.hvals(client.jsticket_redis_key).empty?
end

#refresh_jsticketObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/weixin_authorize/js_ticket/redis_store.rb', line 11

def refresh_jsticket
  super
  weixin_redis.hmset(
    client.jsticket_redis_key,
    JSTICKET,
    client.jsticket,
    EXPIRED_AT,
    client.jsticket_expired_at
  )
  weixin_redis.expireat(
    client.jsticket_redis_key,
    client.jsticket_expired_at.to_i
  )
end

#weixin_redisObject



36
37
38
# File 'lib/weixin_authorize/js_ticket/redis_store.rb', line 36

def weixin_redis
  WeixinAuthorize.weixin_redis
end