cache

package
v0.8.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache(logger *zerolog.Logger, cacheType CacheType, config CacheConfig) (cache.CacheInterface, error)

Types

type CacheConfig

type CacheConfig struct {
	BigCacheConfig  bigcache.Config `json:"bigcache"`
	RedisConfig     redis.Options   `json:"redis"`
	MemCacheServers []string        `json:"memcache_servers"`
	FreeCacheSize   int             `json:"freecache_size"`
	NatsJSConfig    NatsConfig      `json:"nats_js_config"`
	TTL             time.Duration   `json:"ttl"`
}

type CacheType

type CacheType int // definit aici ca enum
const (
	FreeCache CacheType = iota
	Redis
	MemCache
	BigCache
	NatsJSCache
)

func (CacheType) MarshalJSON

func (t CacheType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (CacheType) String

func (t CacheType) String() string

func (*CacheType) UnmarshalJSON

func (t *CacheType) UnmarshalJSON(b []byte) error

UnmarshalJSON un-marshalls a quoted json string to the enum value

type Nats

type Nats struct {
	Conn *nats.Conn
	KV   nats.KeyValue
	// contains filtered or unexported fields
}

func NewNatsJSCache

func NewNatsJSCache(logger *zerolog.Logger, cfg NatsConfig) (*Nats, error)

func (*Nats) Clear

func (n *Nats) Clear(ctx context.Context) error

func (*Nats) Delete

func (n *Nats) Delete(ctx context.Context, key interface{}) error

func (*Nats) Get

func (n *Nats) Get(ctx context.Context, key interface{}) (interface{}, error)

func (*Nats) GetType

func (n *Nats) GetType() string

func (*Nats) Invalidate

func (n *Nats) Invalidate(ctx context.Context, options store.InvalidateOptions) error

func (*Nats) Set

func (n *Nats) Set(ctx context.Context, key, object interface{}, options *store.Options) error

type NatsConfig

type NatsConfig struct {
	CAPath   string
	CertPath string
	KeyPath  string
	Address  string
	KVConfig nats.KeyValueConfig
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL