Class: Capcoauth::OAuth::TTLCache

Inherits:
Object
  • Object
show all
Defined in:
lib/capcoauth/oauth/ttl_cache.rb

Class Method Summary collapse

Class Method Details

.key_for(access_token) ⇒ Object



17
18
19
# File 'lib/capcoauth/oauth/ttl_cache.rb', line 17

def self.key_for(access_token)
  "capcoauth_token:#{access_token}"
end

.remove(access_token) ⇒ Object



13
14
15
# File 'lib/capcoauth/oauth/ttl_cache.rb', line 13

def self.remove(access_token)
  store.delete(key_for(access_token))
end

.storeObject



21
22
23
# File 'lib/capcoauth/oauth/ttl_cache.rb', line 21

def self.store
  Capcoauth.configuration.cache_store
end

.update(access_token, user_id) ⇒ Object



9
10
11
# File 'lib/capcoauth/oauth/ttl_cache.rb', line 9

def self.update(access_token, user_id)
  store.write(key_for(access_token), user_id, expires_in: Capcoauth.configuration.token_verify_ttl)
end

.user_id_for(access_token) ⇒ Object



5
6
7
# File 'lib/capcoauth/oauth/ttl_cache.rb', line 5

def self.user_id_for(access_token)
  store.fetch(key_for(access_token))
end