Package dataloader is an implementation of facebook's dataloader in go. See https://github.com/facebook/dataloader for more information
This section is empty.
This section is empty.
This section is empty.
BatchFunc is a function, which when given a slice of keys (string), returns a slice of `results`. It's important that the length of the input keys matches the length of the output results.
The keys passed to this function are guaranteed to be unique
The Cache interface. If a custom cache is provided, it must implement this interface.
InMemoryCache is an in memory implementation of Cache interface. This simple implementation is well suited for a "per-request" dataloader (i.e. one that only lives for the life of an http request) but it's not well suited for long lived cached items.
NewCache constructs a new InMemoryCache
Clear clears the entire cache
Delete deletes item at `key` from cache
Get gets the value at `key` if it exists, returns value (or nil) and bool indicating of value was found
Set sets the `value` at `key` in the cache
Interface is a `DataLoader` Interface which defines a public API for loading data from a particular data back-end with unique keys such as the `id` column of a SQL table or document name in a MongoDB database, given a batch loading function.
Each `DataLoader` instance should contain a unique memoized cache. Use caution when used in long-lived applications or those which serve many users with different access permissions and consider creating a new instance per web request.
Loader implements the dataloader.Interface.
NewBatchedLoader constructs a new Loader with given options.
Clear clears the value at `key` from the cache, it it exists. Returns self for method chaining
ClearAll clears the entire cache. To be used when some event results in unknown invalidations. Returns self for method chaining.
Load load/resolves the given key, returning a channel that will contain the value and error. The first context passed to this function within a given batch window will be provided to the registered BatchFunc.
LoadMany loads multiple keys, returning a thunk (type: ThunkMany) that will resolve the keys passed in.
Prime adds the provided key and value to the cache. If the key already exists, no change is made. Returns self for method chaining
NoCache implements Cache interface where all methods are noops. This is useful for when you don't want to cache items but still want to use a data loader
NoopTracer is the default (noop) tracer
TraceBatch is a noop function
TraceLoad is a noop function
TraceLoadMany is a noop function
Option allows for configuration of Loader fields.
WithBatchCapacity sets the batch capacity. Default is 0 (unbounded).
WithCache sets the BatchedLoader cache. Defaults to InMemoryCache if a Cache is not set.
WithClearCacheOnBatch allows batching of items but no long term caching. It accomplishes this by clearing the cache after each batch operation.
WithInputCapacity sets the input capacity. Default is 1000.
WithTracer allows tracing of calls to Load and LoadMany
WithWait sets the amount of time to wait before triggering a batch. Default duration is 16 milliseconds.
type PanicErrorWrapper struct { }
PanicErrorWrapper wraps the error interface. This is used to check if the error is a panic error. We should not cache panic errors.
type Result[V any] struct { Data V Error error }
Result is the data structure that a BatchFunc returns. It contains the resolved data, and any errors that may have occurred while fetching the data.
type ResultMany[V any] struct { Data []V Error []error }
ResultMany is used by the LoadMany method. It contains a list of resolved data and a list of errors. The lengths of the data list and error list will match, and elements at each index correspond to each other.
Thunk is a function that will block until the value (*Result) it contains is resolved. After the value it contains is resolved, this function will return the result. This function can be called many times, much like a Promise is other languages. The value will only need to be resolved once so subsequent calls will return immediately.
type ThunkMany[V any] func() ([]V, []error)
ThunkMany is much like the Thunk func type but it contains a list of results.
type TraceBatchFinishFunc[V any] func([]*Result[V])
type TraceLoadFinishFunc[V any] func(Thunk[V])
Tracer is an interface that may be used to implement tracing.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4