Documentation
¶
Index ¶
- Variables
- func Keys[T any](t []T, keyGen func(T) string) []string
- func KeysAndMap[T any](t []T, keyGen func(T) string) ([]string, map[string]T)
- func RangeKeys[T any](keys []string, m map[string]T) []T
- func RangeRevertKeys[T any, R any](keys []string, m map[string]T, revert func(T) R) []R
- type Cache
- func (c *Cache[T]) Del(ctx context.Context, keys ...string) error
- func (c *Cache[T]) Get(ctx context.Context, key string, opts ...Option) (t T, err error)
- func (c *Cache[T]) GetOrFetch(ctx context.Context, key string, fetcher Fetcher[T], opts ...Option) (t T, err error)
- func (c *Cache[T]) HGetAllOrFetch(ctx context.Context, key string, fetcher Fetcher[T], opt ...Option) (t T, err error)
- func (c *Cache[T]) LRange(ctx context.Context, key string, start, stop int, opts ...Option) ([]T, error)
- func (c *Cache[T]) MGetOrFetch(ctx context.Context, keys []string, fetcher MFetcher[T], opts ...Option) (t map[string]T, err error)
- func (c *Cache[T]) Set(ctx context.Context, key string, val T, opts ...Option) error
- func (c *Cache[T]) Setex(ctx context.Context, key string, val T, seconds int, opts ...Option) error
- func (c *Cache[T]) SmembersOrFetch(ctx context.Context, key string, fetcher SortedSetFetcher[T], opts ...Option) ([]T, error)
- type Fetcher
- type JSONSerializer
- type MFetcher
- type MsgPackSerializer
- type Option
- type Serializer
- type SortedSetFetcher
Constants ¶
This section is empty.
Variables ¶
View Source
var ( JSONSer = JSONSerializer{} MsgpackSer = MsgPackSerializer{} )
Functions ¶
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
func (*Cache[T]) GetOrFetch ¶
func (*Cache[T]) HGetAllOrFetch ¶
func (c *Cache[T]) HGetAllOrFetch(ctx context.Context, key string, fetcher Fetcher[T], opt ...Option) (t T, err error)
you need `redis:"field"` tag in T to make this method work. T must be a struct
func (*Cache[T]) MGetOrFetch ¶
func (*Cache[T]) SmembersOrFetch ¶
type JSONSerializer ¶
type JSONSerializer struct{}
type MsgPackSerializer ¶
type MsgPackSerializer struct{}
type Option ¶
type Option func(*cacheOption)
func WithSerializer ¶
func WithSerializer(ser Serializer) Option
type Serializer ¶
Click to show internal directories.
Click to hide internal directories.