MCPcopy Create free account
hub / github.com/koding/kite / cacheToken

Method cacheToken

kontrol/kontrol.go:543–556  ·  view source on GitHub ↗

cacheToken cached the signed token under the given key. It also ensures the token is invalidated after its expiration time. If the token was already exists in the cache, it will be overwritten with a new value.

(key, signed string)

Source from the content-addressed store, hash-verified

541// If the token was already exists in the cache, it will be
542// overwritten with a new value.
543func (k *Kontrol) cacheToken(key, signed string) {
544 if ct, ok := k.tokenCache[key]; ok {
545 ct.timer.Stop()
546 }
547
548 k.tokenCache[key] = cachedToken{
549 signed: signed,
550 timer: time.AfterFunc(k.tokenTTL()-k.tokenLeeway(), func() {
551 k.tokenCacheMu.Lock()
552 delete(k.tokenCache, key)
553 k.tokenCacheMu.Unlock()
554 }),
555 }
556}
557
558// generateToken returns a JWT token string. Please see the URL for details:
559// http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-13#section-4.1

Callers 1

generateTokenMethod · 0.95

Calls 2

tokenTTLMethod · 0.95
tokenLeewayMethod · 0.95

Tested by

no test coverage detected