adapters

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCacheableType error = errors.New("cacheable should be of type lfuCache")
	ErrValueType     error = errors.New("cached value type is strange")
)
View Source
var (
	ErrKeyNotExists error = errors.New("key doesnt not exists")
)

Functions

This section is empty.

Types

type Cacheable

type Cacheable interface {
	fmt.Stringer
	GetKey(string) string
	GetPair(string) (string, string, error) //key, value, error
	ParseValue(value string) error
}

type Cacher

type Cacher interface {
	Cache(cacheable Cacheable) error
	GetCachable(cacheable Cacheable) error
}

type MemoryClient

type MemoryClient[T Cacheable] struct {
	LogEntry *log.Entry
	Prefix   string
	// contains filtered or unexported fields
}

func NewMemoryClient

func NewMemoryClient[T Cacheable](logEntry *log.Entry, prefix string, cap int) *MemoryClient[T]

func (*MemoryClient[T]) Cache

func (mc *MemoryClient[T]) Cache(cacheable Cacheable) error

func (*MemoryClient[T]) GetCachable

func (mc *MemoryClient[T]) GetCachable(cacheable Cacheable) error

type RedisClient

type RedisClient struct {
	LogEntry   *log.Entry
	Prefix     string
	Client     *redis.Client
	Expiration time.Duration
}

func NewRedisClient

func NewRedisClient(logEntry *log.Entry, prefix string, addr string, password string, db int, timeout time.Duration, expiration time.Duration) *RedisClient

func (*RedisClient) Cache

func (rc *RedisClient) Cache(cacheable Cacheable) error

func (*RedisClient) GetCachable

func (rc *RedisClient) GetCachable(cacheable Cacheable) error

Jump to

Keyboard shortcuts

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