Documentation ¶
Index ¶
- type Store
- func (s *Store[T]) Delete(key string)
- func (s *Store[T]) Flush()
- func (s *Store[T]) GetOrSet(key string, getValue func() (T, error)) (T, error)
- func (s *Store[T]) GetOrSetWithTTL(key string, getValue func() (T, error), ttl time.Duration) (T, error)
- func (s *Store[T]) ResetRefresher(interval time.Duration)
- func (s *Store[T]) StopRefresher()
- type StoreOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store[T interface{}] struct {
// contains filtered or unexported fields
}
func (*Store[T]) GetOrSet ¶
GetOrSet gets cache value T, or set the value T that returns getValue. If getValue does not return err, cache the value T.
func (*Store[T]) GetOrSetWithTTL ¶
func (s *Store[T]) GetOrSetWithTTL(key string, getValue func() (T, error), ttl time.Duration) (T, error)
GetOrSet gets cache value T, or set the value T that returns getValue with TTL. If getValue does not return err, cache the value T.
func (*Store[T]) ResetRefresher ¶
func (*Store[T]) StopRefresher ¶
func (s *Store[T]) StopRefresher()
type StoreOption ¶
type StoreOption[T interface{}] func(*Store[T])
func WithDefaultTTL ¶
func WithDefaultTTL[T interface{}](ttl time.Duration) StoreOption[T]
func WithRefreshInterval ¶
func WithRefreshInterval[T interface{}](interval time.Duration) StoreOption[T]
Click to show internal directories.
Click to hide internal directories.