Sha256: a6db884833add9266d0cfc4c9ea553a473b1b5a93be536efa083c8ef9930c829

Contents?: true

Size: 509 Bytes

Versions: 5

Compression:

Stored size: 509 Bytes

Contents

module Capcoauth
  module OAuth
    class TTLCache
      @@cache = {}

      def self.valid?(access_token)
        purge
        !!@@cache[access_token]
      end

      def self.update(access_token)
        @@cache[access_token] = Time.zone.now
      end

      def self.remove(access_token)
        @@cache.delete(access_token)
      end

      def self.purge
        @@cache.delete_if do |k, v|
          Time.zone.now > v + Capcoauth.configuration.token_verify_ttl
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
capcoauth-0.2.0 lib/capcoauth/oauth/ttl_cache.rb
capcoauth-0.1.4 lib/capcoauth/oauth/ttl_cache.rb
capcoauth-0.1.3 lib/capcoauth/oauth/ttl_cache.rb
capcoauth-0.1.2 lib/capcoauth/oauth/ttl_cache.rb
capcoauth-0.1.1 lib/capcoauth/oauth/ttl_cache.rb