Documentation ¶
Index ¶
- Constants
- func DefaultPostActionErrorHandler[T any](ctx context.Context, args PostActionErrorHandlerArgs[T]) (T, error)
- func DefaultPreActionErrorHandler[T any](ctx context.Context, args PreActionErrorHandlerArgs[T]) (T, error)
- type ActionFunc
- type ActionResult
- type Actor
- type ActorOptions
- type Keyable
- type KeyableMap
- type KeyableStr
- type PostActionErrorHandlerArgs
- type PostActionErrorHandlerFunc
- type PreActionErrorHandlerArgs
- type PreActionErrorHandlerFunc
Constants ¶
View Source
const (
TTLDefault = time.Duration(10) * time.Minute
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActionResult ¶
type Actor ¶
type Actor[T any] interface { // Set default TTL of cache. SetTTL(ttl time.Duration) Actor[T] // Set error handler for handling unconventional errors thrown before action (get in cache and lock). // // Value and error returned by the handler will be forwarded as a return value for Actor.Do. SetPreActionErrorHandler(handler PreActionErrorHandlerFunc[T]) Actor[T] // Set error handler for handling unconventional errors thrown after action (store). // // Value and error returned by the handler will be forwarded as a return value for Actor.Do. SetPostActionErrorHandler(handler PostActionErrorHandlerFunc[T]) Actor[T] // Invalidate the value of the given key. Invalidate(ctx context.Context, key Keyable) error // Perform an action. // The action will not be executed again if the key exists in cache. Do(ctx context.Context, key Keyable, action ActionFunc[T]) (T, error) }
type ActorOptions ¶ added in v0.2.0
type KeyableMap ¶
type KeyableStr ¶ added in v0.2.0
type KeyableStr string
type PostActionErrorHandlerArgs ¶
type PostActionErrorHandlerArgs[T any] struct { Key Keyable Action ActionFunc[T] Result ActionResult[T] ErrCategory string Err error }
type PreActionErrorHandlerArgs ¶
type PreActionErrorHandlerArgs[T any] struct { Key Keyable Action ActionFunc[T] ErrCategory string Err error }
Click to show internal directories.
Click to hide internal directories.