data

package
v0.0.0-...-087ca59 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLoader

func AddLoader[TKey comparable, T any](opts *LoaderOptions, loader ILoaderFactory[TKey, *T])

func AddLoaderFunc

func AddLoaderFunc[TKey comparable, T any](opts *LoaderOptions, batchFunc TypedBatchFunc[TKey, T])

func AddNamedLoaderFunc

func AddNamedLoaderFunc[TKey comparable, T any](opts *LoaderOptions, name string, batchFunc TypedBatchFunc[TKey, T])

func GetLoader

func GetLoader[TKey comparable, T any](ctx context.Context, name string) *dataloader.Loader[TKey, T]

func GetTypedLoader

func GetTypedLoader[TKey comparable, T any](ctx context.Context) *dataloader.Loader[TKey, T]

func WithDataLoaderCache

func WithDataLoaderCache(ctx context.Context) context.Context

Types

type ILoaderFactory

type ILoaderFactory[TKey comparable, T any] interface {
	Name() string
	CreateLoader() *dataloader.Loader[TKey, T]
}

type InContextCache

type InContextCache[TKey comparable, TValue any] struct {
	// contains filtered or unexported fields
}

func NewContextCache

func NewContextCache[TKey comparable, TValue any](name string) *InContextCache[TKey, TValue]

NewContextCache constructs a new InMemoryCache

func (*InContextCache[TKey, TValue]) Clear

func (c *InContextCache[TKey, TValue]) Clear()

Clear clears the cache

func (*InContextCache[TKey, TValue]) Delete

func (c *InContextCache[TKey, TValue]) Delete(ctx context.Context, key TKey) bool

Delete deletes item at `key` from cache

func (*InContextCache[TKey, TValue]) Get

func (c *InContextCache[TKey, TValue]) Get(ctx context.Context, key TKey) (dataloader.Thunk[TValue], bool)

Get gets the value at `key` if it exists, returns value (or nil) and bool indicating of value was found

func (*InContextCache[TKey, TValue]) Set

func (c *InContextCache[TKey, TValue]) Set(ctx context.Context, key TKey, value dataloader.Thunk[TValue])

Set sets the `value` at `key` in the cache

type LoaderFactory

type LoaderFactory[TKey comparable, T any] struct {
	// contains filtered or unexported fields
}

func NewLoaderWithName

func NewLoaderWithName[TKey comparable, TResult any](name string, batchFunc TypedBatchFunc[TKey, TResult]) *LoaderFactory[TKey, TResult]

func NewTypedLoader

func NewTypedLoader[TKey comparable, TResult any](batchFunc TypedBatchFunc[TKey, TResult]) *LoaderFactory[TKey, TResult]

func (*LoaderFactory[TKey, T]) CreateLoader

func (tl *LoaderFactory[TKey, T]) CreateLoader() *dataloader.Loader[TKey, T]

func (*LoaderFactory[TKey, T]) Load

func (tl *LoaderFactory[TKey, T]) Load(ctx context.Context, keys []TKey) []*dataloader.Result[T]

func (*LoaderFactory[TKey, T]) Name

func (tl *LoaderFactory[TKey, T]) Name() string

type LoaderOptions

type LoaderOptions struct {
	Loaders map[string]any
}

func NewLoaderOptions

func NewLoaderOptions() *LoaderOptions

func (*LoaderOptions) GetLoader

func (lo *LoaderOptions) GetLoader(name string) any

type TypedBatchFunc

type TypedBatchFunc[TKey, T any] func(context.Context, []TKey) []T

Jump to

Keyboard shortcuts

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