Documentation
¶
Overview ¶
Package cache memoizes the outcome of verifying a credential. A sync client presents the same secret on every request, which otherwise costs a database or identity provider lookup every time. It does not matter what the credential is: an app password, a username and password, a public link token or a signed JWT all go through the same cache. Rejections are cached too, so a client that keeps retrying a stale password is also answered from memory.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is safe for concurrent use.
func New ¶
New applies the defaults to the zero fields of c. A negative TTL disables the cache: it then stores nothing and never reports a hit.
func (*Cache) Get ¶
Get returns the identity, the error that rejected the credential, and whether the key was cached at all.
type Config ¶
type Config struct {
Size int `mapstructure:"cache_size" docs:"50000;Maximum number of authentication outcomes kept in memory."`
TTL int `` /* 184-byte string literal not displayed */
NegativeTTL int `mapstructure:"negative_cache_ttl" docs:"30;Seconds a rejected credential stays cached."`
}
Embed Config in a service configuration with `mapstructure:",squash"`.