Documentation ¶
Index ¶
- type BadgerConfig
- type Cacher
- func NewBadgerCache(cfg BadgerConfig, opts ...Option) Cacher
- func NewMemoryCache(cfg MemoryConfig, opts ...Option) Cacher
- func NewRedisCache(cfg RedisConfig, opts ...Option) Cacher
- func NewRedisCacheWithClient(cli *redis.Client, opts ...Option) Cacher
- func NewRedisCacheWithClusterClient(cli *redis.ClusterClient, opts ...Option) Cacher
- type MemoryConfig
- type Option
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BadgerConfig ¶
type BadgerConfig struct {
Path string
}
type Cacher ¶
type Cacher interface { Set(ctx context.Context, ns, key, value string, expiration ...time.Duration) error Get(ctx context.Context, ns, key string) (string, bool, error) GetAndDelete(ctx context.Context, ns, key string) (string, bool, error) Exists(ctx context.Context, ns, key string) (bool, error) Delete(ctx context.Context, ns, key string) error Iterator(ctx context.Context, ns string, fn func(ctx context.Context, key, value string) bool) error Close(ctx context.Context) error }
Cacher is the interface that wraps the basic Get, Set, and Delete methods.
func NewBadgerCache ¶
func NewBadgerCache(cfg BadgerConfig, opts ...Option) Cacher
Create badger-based cache
func NewMemoryCache ¶
func NewMemoryCache(cfg MemoryConfig, opts ...Option) Cacher
func NewRedisCache ¶
func NewRedisCache(cfg RedisConfig, opts ...Option) Cacher
Create redis-based cache
func NewRedisCacheWithClient ¶
Use redis client create cache
func NewRedisCacheWithClusterClient ¶
Use redis cluster client create cache
type MemoryConfig ¶
Click to show internal directories.
Click to hide internal directories.