An atproto PDS written in Go
1package dpop 2 3import ( 4 "sync" 5 "time" 6 7 cache "github.com/go-pkgz/expirable-cache/v3" 8 "github.com/haileyok/cocoon/oauth/constants" 9) 10 11type jtiCache struct { 12 mu sync.Mutex 13 cache cache.Cache[string, bool] 14} 15 16func newJTICache(size int) *jtiCache { 17 cache := cache.NewCache[string, bool]().WithTTL(24 * time.Hour).WithLRU().WithTTL(constants.JTITtl) 18 return &jtiCache{ 19 cache: cache, 20 mu: sync.Mutex{}, 21 } 22} 23 24func (c *jtiCache) add(jti string) bool { 25 c.mu.Lock() 26 defer c.mu.Unlock() 27 return c.cache.Add(jti, true) 28}