Documentation ¶
Index ¶
- type Cache
- type ClearUserToken
- type ExternalCache
- func (c *ExternalCache) Add(u gimlet.User) error
- func (c *ExternalCache) Clear(u gimlet.User, all bool) error
- func (c *ExternalCache) Find(id string) (gimlet.User, bool, error)
- func (c *ExternalCache) Get(token string) (gimlet.User, bool, error)
- func (c *ExternalCache) GetOrCreate(u gimlet.User) (gimlet.User, error)
- func (c *ExternalCache) Put(u gimlet.User) (string, error)
- type ExternalOptions
- type GetOrCreateUser
- type GetUserByID
- type GetUserByToken
- type PutUserGetToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { Add(gimlet.User) error Put(gimlet.User) (string, error) Clear(gimlet.User, bool) error GetOrCreate(gimlet.User) (gimlet.User, error) Get(token string) (u gimlet.User, valid bool, err error) Find(id string) (u gimlet.User, valid bool, err error) }
func NewExternal ¶
func NewExternal(opts ExternalOptions) (Cache, error)
NewExternal returns an external user cache.
type ClearUserToken ¶
ClearUserToken is a function provided by the client to remove users' tokens from cache. Passing true will ignore the user passed and clear all users.
type ExternalCache ¶
type ExternalCache struct {
Opts ExternalOptions
}
func (*ExternalCache) GetOrCreate ¶
type ExternalOptions ¶
type ExternalOptions struct { PutUserGetToken PutUserGetToken GetUserByToken GetUserByToken ClearUserToken ClearUserToken GetUserByID GetUserByID GetOrCreateUser GetOrCreateUser }
ExternalOptions provides functions to inject the functionality of the user cache from an external source.
func (ExternalOptions) Validate ¶
func (opts ExternalOptions) Validate() error
type GetOrCreateUser ¶
GetOrCreateUser is a function provided by the client to get a user from persistent storage, or if the user does not exist, to create and save it.
type GetUserByID ¶
GetUserByID is a function provided by the client to get a user from persistent storage.
type GetUserByToken ¶
GetUserByToken is a function provided by the client to retrieve cached users by token. It returns an error if and only if there was an error retrieving the user from the cache. It returns (<user>, true, nil) if the user is present in the cache and is valid. It returns (<user>, false, nil) if the user is present in the cache but has expired. It returns (nil, false, nil) if the user is not present in the cache.