Documentation
¶
Index ¶
- type ObjectSessionsCache
- func (ch *ObjectSessionsCache) AuthenticateTokenV1(tokenKey [sha256.Size]byte, authOnMiss func() (session.Object, error)) (session.Object, error)
- func (ch *ObjectSessionsCache) AuthenticateTokenV2(tokenKey [sha256.Size]byte, authOnMiss func() (sessionv2.Token, error)) (sessionv2.Token, error)
- func (ch *ObjectSessionsCache) ResetCache()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObjectSessionsCache ¶
type ObjectSessionsCache struct {
// contains filtered or unexported fields
}
ObjectSessionsCache caches object session tokens based on their hashes, both v1 and v2 versions. Caches are LRU, there is no garanty a put token will be available later.
func NewObjectSessionsCache ¶
func NewObjectSessionsCache(cacheSize int) *ObjectSessionsCache
NewObjectSessionsCache creates ObjectSessionsCache with a provided size. Caches for v1 and v2 tokens are independent. Size must be positive.
func (*ObjectSessionsCache) AuthenticateTokenV1 ¶
func (ch *ObjectSessionsCache) AuthenticateTokenV1(tokenKey [sha256.Size]byte, authOnMiss func() (session.Object, error)) (session.Object, error)
AuthenticateTokenV1 checks whether v1 token was cached as a correctly signed one. On cache miss, authOnMiss is called and its result is saved for future calls with the same tokenKey. tokenKey must be the same for the same token for cache to work properly.
func (*ObjectSessionsCache) AuthenticateTokenV2 ¶
func (ch *ObjectSessionsCache) AuthenticateTokenV2(tokenKey [sha256.Size]byte, authOnMiss func() (sessionv2.Token, error)) (sessionv2.Token, error)
AuthenticateTokenV2 works the same as ObjectSessionsCache.AuthenticateTokenV1 but for v2 session tokens.
func (*ObjectSessionsCache) ResetCache ¶
func (ch *ObjectSessionsCache) ResetCache()
ResetCache resets all cached tokens.