cache

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadgerCache

type BadgerCache struct {
	Connection *badger.DB
	Prefix     string
}

BadgerCache

TODO: add own logger

func CreateBadgerCache

func CreateBadgerCache(c BadgerConfig, log ...*logger.Logger) (*BadgerCache, error)

func (*BadgerCache) Close

func (b *BadgerCache) Close() error

func (*BadgerCache) Empty

func (b *BadgerCache) Empty() error

func (*BadgerCache) EmptyByMatch

func (b *BadgerCache) EmptyByMatch(key string) error

func (*BadgerCache) Forget

func (b *BadgerCache) Forget(key string) error

func (*BadgerCache) Get

func (b *BadgerCache) Get(key string) (interface{}, error)

func (*BadgerCache) GetConnection

func (b *BadgerCache) GetConnection() any

func (*BadgerCache) Has

func (b *BadgerCache) Has(str string) (bool, error)

func (*BadgerCache) Set

func (b *BadgerCache) Set(key string, value interface{}, expires ...int) error

type BadgerConfig

type BadgerConfig struct {
	Prefix string
	Path   string // Path is the full path to badger
}

type BadgerLogger

type BadgerLogger struct {
	*logger.Logger
}

BadgerLogger replaces the default badger logger with a zerolog logger

func (*BadgerLogger) Debugf

func (bl *BadgerLogger) Debugf(msg string, v ...interface{})

func (*BadgerLogger) Errorf

func (bl *BadgerLogger) Errorf(msg string, v ...interface{})

func (*BadgerLogger) Infof

func (bl *BadgerLogger) Infof(msg string, v ...interface{})

func (*BadgerLogger) Warningf

func (bl *BadgerLogger) Warningf(msg string, v ...interface{})

type Cache

type Cache interface {
	// GetConnection returns the underlying connection which can be casted to the respective type
	GetConnection() any

	// Close closes the cache pool
	Close() error

	Has(key string) (bool, error)
	Get(key string) (interface{}, error)
	Set(key string, value interface{}, expiry ...int) error
	Forget(key string) error
	EmptyByMatch(key string) error
	Empty() error
}

type Entry

type Entry map[string]interface{}

type RedisCache

type RedisCache struct {
	Pool   *redis.Pool
	Prefix string
}

func CreateRedisCache

func CreateRedisCache(c RedisConfig) (*RedisCache, error)

func (*RedisCache) Close

func (r *RedisCache) Close() error

func (*RedisCache) Empty

func (c *RedisCache) Empty() error

func (*RedisCache) EmptyByMatch

func (c *RedisCache) EmptyByMatch(key string) error

func (*RedisCache) Forget

func (c *RedisCache) Forget(key string) error

func (*RedisCache) Get

func (c *RedisCache) Get(key string) (interface{}, error)

func (*RedisCache) GetConnection

func (r *RedisCache) GetConnection() any

func (*RedisCache) Has

func (c *RedisCache) Has(key string) (bool, error)

func (*RedisCache) Set

func (c *RedisCache) Set(key string, value interface{}, expires ...int) error

type RedisConfig

type RedisConfig struct {
	Prefix   string
	Host     string
	Port     string
	Password string
}

Jump to

Keyboard shortcuts

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