Documentation ¶
Index ¶
- Variables
- func KeyNotFoundError(k any) error
- func KeyRejectedError(k any) error
- type DataLoader
- func (d *DataLoader[K, V]) Load(ctx context.Context, k K) Promise[V]
- func (d *DataLoader[K, V]) LoadMany(ctx context.Context, ks []K) Promises[V]
- func (d *DataLoader[K, V]) Set(ctx context.Context, k K, v V)
- func (d *DataLoader[K, V]) SetNX(ctx context.Context, k K, v V) bool
- func (d *DataLoader[K, V]) Stop()
- type Option
- type Promise
- type Promises
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKeyNotFound = errors.New("dataloader: key not found") ErrKeyRejected = errors.New("dataloader: key rejected") )
Functions ¶
func KeyNotFoundError ¶
func KeyRejectedError ¶
Types ¶
type DataLoader ¶
type DataLoader[K comparable, V any] struct { // contains filtered or unexported fields }
func New ¶
func New[K comparable, V any](opt Option[K, V]) *DataLoader[K, V]
func (*DataLoader[K, V]) Load ¶
func (d *DataLoader[K, V]) Load(ctx context.Context, k K) Promise[V]
func (*DataLoader[K, V]) LoadMany ¶
func (d *DataLoader[K, V]) LoadMany(ctx context.Context, ks []K) Promises[V]
func (*DataLoader[K, V]) Set ¶
func (d *DataLoader[K, V]) Set(ctx context.Context, k K, v V)
Set sets the key-value after expiring existing references.
func (*DataLoader[K, V]) SetNX ¶
func (d *DataLoader[K, V]) SetNX(ctx context.Context, k K, v V) bool
SetNX sets the key-value, only if the entry does not exists. This prevents issue with references.
func (*DataLoader[K, V]) Stop ¶
func (d *DataLoader[K, V]) Stop()
Click to show internal directories.
Click to hide internal directories.