slice

package
v0.0.0-...-314ac81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserSliceLoader

type UserSliceLoader struct {
	// contains filtered or unexported fields
}

UserSliceLoader batches and caches requests

func NewLoader

func NewLoader() *UserSliceLoader

func (*UserSliceLoader) Clear

func (l *UserSliceLoader) Clear(key int)

Clear the value at key from the cache, if it exists

func (*UserSliceLoader) Load

func (l *UserSliceLoader) Load(key int) ([]example.User, error)

Load a user by key, batching and caching will be applied automatically

func (*UserSliceLoader) LoadAll

func (l *UserSliceLoader) LoadAll(keys []int) ([][]example.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 (*UserSliceLoader) LoadThunk

func (l *UserSliceLoader) LoadThunk(key int) func() ([]example.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.

func (*UserSliceLoader) Prime

func (l *UserSliceLoader) Prime(key int, value []example.User) bool

Prime the cache with the provided key and value. If the key already exists, no change is made and false is returned. (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL