Sha256: edd90a4e72c29ec1a3f121c8ff789c0c4fe6fc80aea4be205fae464ef559e3f9

Contents?: true

Size: 726 Bytes

Versions: 8

Compression:

Stored size: 726 Bytes

Contents

module Wework
  module JsTicket
    class RedisStore < Store

      def initialize(agent)
        raise RedisNotConfigException if redis.nil?
        super
      end

      def jsapi_ticket
        super
        redis.hget(key, "ticket")
      end

      def expired?
        redis.hvals(key).empty?
      end

      def refresh_token
        result = super
        if result.success?
          expires_at = Time.now.to_i + result.expires_in.to_i - 100
          redis.hmset(
            key,
            "ticket", result.ticket,
            "expires_at", expires_at
          )

          redis.expireat(key, expires_at)
        end
      end

      private

      def redis
        Wework.redis
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
wework-0.2.4 lib/wework/js_ticket/redis_store.rb
wework-0.2.3 lib/wework/js_ticket/redis_store.rb
wework-0.2.2 lib/wework/js_ticket/redis_store.rb
wework-0.2.0 lib/wework/js_ticket/redis_store.rb
wework-0.1.9 lib/wework/js_ticket/redis_store.rb
wework-0.1.8 lib/wework/js_ticket/redis_store.rb
wework-0.1.7 lib/wework/js_ticket/redis_store.rb
wework-0.1.6 lib/wework/js_ticket/redis_store.rb