Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UserLoader ¶
type UserLoader struct {
// contains filtered or unexported fields
}
UserLoader batches and caches requests
func NewLoader ¶
func NewLoader() *UserLoader
NewLoader will collect user requests for 2 milliseconds and send them as a single batch to the fetch func normally fetch would be a database call.
func (*UserLoader) Clear ¶
func (l *UserLoader) Clear(key string)
Clear the value at key from the cache, if it exists
func (*UserLoader) Load ¶
func (l *UserLoader) Load(key string) (*User, error)
Load a user by key, batching and caching will be applied automatically
func (*UserLoader) LoadAll ¶
func (l *UserLoader) LoadAll(keys []string) ([]*User, []error)
LoadAll fetches many keys at once. It will be broken into appropriate sized sub batches depending on how the loader is configured
func (*UserLoader) LoadThunk ¶
func (l *UserLoader) LoadThunk(key string) func() (*User, error)
LoadThunk returns a function that when called will block waiting for a user. This method should be used if you want one goroutine to make requests to many different data loaders without blocking until the thunk is called.