Versions in this module Expand all Collapse all v0 v0.15.0 Oct 16, 2023 Changes in this version + var ErrInvalidStrategyResult = errors.New("invalid strategy result") + func WithDefaultStrategyCallback[K comparable, V any](callback StrategyCallback) trcache.RootOption + func WithDeleteStrategyCallback[K comparable, V any](callback StrategyCallback) trcache.DeleteOption + func WithDeleteStrategy[K comparable, V any](deleteStrategy DeleteStrategy[K, V]) trcache.RootOption + func WithGetSetOptions[K comparable, V any](options ...trcache.SetOption) trcache.GetOption + func WithGetStrategyCallback[K comparable, V any](callback StrategyCallback) trcache.GetOption + func WithGetStrategy[K comparable, V any](getStrategy GetStrategy[K, V]) trcache.RootOption + func WithSetStrategyCallback[K comparable, V any](callback StrategyCallback) trcache.SetOption + func WithSetStrategy[K comparable, V any](setStrategy SetStrategy[K, V]) trcache.RootOption + type Chain struct + func New[K comparable, V any](cache []trcache.Cache[K, V], options ...trcache.RootOption) (*Chain[K, V], error) + func (c *Chain[K, V]) Delete(ctx context.Context, key K, options ...trcache.DeleteOption) error + func (c *Chain[K, V]) Get(ctx context.Context, key K, options ...trcache.GetOption) (V, error) + func (c *Chain[K, V]) Name() string + func (c *Chain[K, V]) Set(ctx context.Context, key K, value V, options ...trcache.SetOption) error + type ChainError struct + Err error + ErrType ChainErrorType + Message string + func NewChainError(errType ChainErrorType, message string, err error) ChainError + func (e ChainError) As(target any) bool + func (e ChainError) Error() string + func (e ChainError) Is(err error) bool + type ChainErrorType int + const ChainErrorTypeError + const ChainErrorTypeIncomplete + type ChainRefresh struct + func NewRefresh[K comparable, V any](cache []trcache.Cache[K, V], options ...trcache.RootOption) (*ChainRefresh[K, V], error) + func (c *ChainRefresh[K, V]) GetOrRefresh(ctx context.Context, key K, options ...trcache.RefreshOption) (V, error) + type DeleteStrategy interface + AfterDelete func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, err error) DeleteStrategyAfterResult + BeforeDelete func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) DeleteStrategyBeforeResult + DeleteLoopOrder func(ctx context.Context) StrategyLoopOrder + func NewDefaultDeleteStrategy[K comparable, V any]() DeleteStrategy[K, V] + type DeleteStrategyAfterResult int + const DeleteStrategyAfterResultCONTINUE + const DeleteStrategyAfterResultCONTINUEWITHERROR + const DeleteStrategyAfterResultRETURN + type DeleteStrategyBeforeResult int + const DeleteStrategyBeforeResultDELETE + const DeleteStrategyBeforeResultSKIP + type DeleteStrategyDeleteAll struct + func (f DeleteStrategyDeleteAll[K, V]) AfterDelete(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, err error) DeleteStrategyAfterResult + func (f DeleteStrategyDeleteAll[K, V]) BeforeDelete(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) DeleteStrategyBeforeResult + func (f DeleteStrategyDeleteAll[K, V]) DeleteLoopOrder(ctx context.Context) StrategyLoopOrder + type DeleteStrategyFunc struct + AfterDeleteFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, err error) DeleteStrategyAfterResult + BeforeDeleteFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) DeleteStrategyBeforeResult + DeleteLoopOrderFn func(ctx context.Context) StrategyLoopOrder + func (f DeleteStrategyFunc[K, V]) AfterDelete(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, err error) DeleteStrategyAfterResult + func (f DeleteStrategyFunc[K, V]) BeforeDelete(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) DeleteStrategyBeforeResult + func (f DeleteStrategyFunc[K, V]) DeleteLoopOrder(ctx context.Context) StrategyLoopOrder + type GetStrategy interface + AfterGet func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) GetStrategyAfterResult + AfterSet func(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyAfterSetResult + BeforeGet func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) GetStrategyBeforeResult + BeforeSet func(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyBeforeSetResult + GetLoopOrder func(ctx context.Context) StrategyLoopOrder + SetLoopOrder func(ctx context.Context) StrategyLoopOrder + func NewDefaultGetStrategy[K comparable, V any]() GetStrategy[K, V] + type GetStrategyAfterResult int + const GetStrategyAfterResultRETURN + const GetStrategyAfterResultSKIP + type GetStrategyAfterSetResult int + const GetStrategyAfterSetResultCONTINUE + const GetStrategyAfterSetResultRETURN + type GetStrategyBeforeResult int + const GetStrategyBeforeResultGET + const GetStrategyBeforeResultSKIP + type GetStrategyBeforeSetResult int + const GetStrategyBeforeSetResultSET + const GetStrategyBeforeSetResultSKIP + type GetStrategyFunc struct + AfterGetFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) GetStrategyAfterResult + AfterSetFn func(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyAfterSetResult + BeforeGetFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) GetStrategyBeforeResult + BeforeSetFn func(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyBeforeSetResult + GetLoopOrderFn func(ctx context.Context) StrategyLoopOrder + SetLoopOrderFn func(ctx context.Context) StrategyLoopOrder + func (f GetStrategyFunc[K, V]) AfterGet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) GetStrategyAfterResult + func (f GetStrategyFunc[K, V]) AfterSet(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyAfterSetResult + func (f GetStrategyFunc[K, V]) BeforeGet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) GetStrategyBeforeResult + func (f GetStrategyFunc[K, V]) BeforeSet(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyBeforeSetResult + func (f GetStrategyFunc[K, V]) GetLoopOrder(ctx context.Context) StrategyLoopOrder + func (f GetStrategyFunc[K, V]) SetLoopOrder(ctx context.Context) StrategyLoopOrder + type GetStrategyGetFirstSetPrevious struct + func (f GetStrategyGetFirstSetPrevious[K, V]) AfterGet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) GetStrategyAfterResult + func (f GetStrategyGetFirstSetPrevious[K, V]) AfterSet(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyAfterSetResult + func (f GetStrategyGetFirstSetPrevious[K, V]) BeforeGet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K) GetStrategyBeforeResult + func (f GetStrategyGetFirstSetPrevious[K, V]) BeforeSet(ctx context.Context, gotCacheIdx, cacheIdx int, cache trcache.Cache[K, V], ...) GetStrategyBeforeSetResult + func (f GetStrategyGetFirstSetPrevious[K, V]) GetLoopOrder(ctx context.Context) StrategyLoopOrder + func (f GetStrategyGetFirstSetPrevious[K, V]) SetLoopOrder(ctx context.Context) StrategyLoopOrder + type SetStrategy interface + AfterSet func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) SetStrategyAfterResult + BeforeSet func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V) SetStrategyBeforeResult + SetLoopOrder func(ctx context.Context) StrategyLoopOrder + func NewDefaultSetStrategy[K comparable, V any]() SetStrategy[K, V] + type SetStrategyAfterResult int + const SetStrategyAfterResultCONTINUE + const SetStrategyAfterResultCONTINUEWITHERROR + const SetStrategyAfterResultRETURN + type SetStrategyBeforeResult int + const SetStrategyBeforeResultSET + const SetStrategyBeforeResultSKIP + type SetStrategyFunc struct + AfterSetFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) SetStrategyAfterResult + BeforeSetFn func(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V) SetStrategyBeforeResult + SetLoopOrderFn func(ctx context.Context) StrategyLoopOrder + func (f SetStrategyFunc[K, V]) AfterSet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) SetStrategyAfterResult + func (f SetStrategyFunc[K, V]) BeforeSet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V) SetStrategyBeforeResult + func (f SetStrategyFunc[K, V]) SetLoopOrder(ctx context.Context) StrategyLoopOrder + type SetStrategySetAll struct + func (f SetStrategySetAll[K, V]) AfterSet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V, ...) SetStrategyAfterResult + func (f SetStrategySetAll[K, V]) BeforeSet(ctx context.Context, cacheIdx int, cache trcache.Cache[K, V], key K, value V) SetStrategyBeforeResult + func (f SetStrategySetAll[K, V]) SetLoopOrder(ctx context.Context) StrategyLoopOrder + type StrategyCallback interface + Delete func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + Get func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + GetSet func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + Set func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + type StrategyCallbackFunc struct + DeleteFn func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + GetFn func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + GetSetFn func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + SetFn func(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + func (s *StrategyCallbackFunc) Delete(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + func (s *StrategyCallbackFunc) Get(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + func (s *StrategyCallbackFunc) GetSet(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + func (s *StrategyCallbackFunc) Set(ctx context.Context, cacheIdx int, cacheName string, key any, err error, ...) + type StrategyLoopOrder int + const StrategyLoopOrderBACKWARD + const StrategyLoopOrderFORWARD