cache

package
v0.0.0-...-035f276 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMissingKeyCacheError

func IsMissingKeyCacheError(err error) bool

func NewMissingKeyCacheError

func NewMissingKeyCacheError(key string) error

func NewNegativeExpirationCacheError

func NewNegativeExpirationCacheError(expiration time.Duration) error

Types

type FreeCacheInMemCacheClient

type FreeCacheInMemCacheClient struct {
	// contains filtered or unexported fields
}

FreeCacheInMemCacheClient is in-mem cache. it wraps freecache.Cache struct. For more information regarding this cache - "https://github.com/coocood/freecache".

func NewFreeCacheInMemCacheClient

func NewFreeCacheInMemCacheClient(instrumentationProvider instrumentation.IInstrumentationProvider, cache wrappers.IFreeCacheInMemCacheWrapper) *FreeCacheInMemCacheClient

NewFreeCacheInMemCacheClient is constructor for FreeCacheInMemCacheClient.

func (*FreeCacheInMemCacheClient) Get

func (client *FreeCacheInMemCacheClient) Get(key string) (string, error)

Get a key from FreeInMemCache. Returns MissingKeyCacheError if ket is not exist.

func (*FreeCacheInMemCacheClient) Set

func (client *FreeCacheInMemCacheClient) Set(key string, value string, expiration time.Duration) error

Set

type ICacheClient

type ICacheClient interface {
	// Get gets a value from the cache. It returns  error when key does not exist.
	Get(key string) (string, error)

	//Set sets new item in the cache.
	//Zero expiration means the key has no expiration time.
	// It returns error when there was a problem trying to set the key.
	Set(key string, value string, expiration time.Duration) error
}

ICacheClient is a basic cache client interface.

type MissingKeyCacheError

type MissingKeyCacheError struct {
	// contains filtered or unexported fields
}

MissingKeyCacheError is error that represent that is returned when ICacheClient is missing key on get method.

func (*MissingKeyCacheError) Error

func (err *MissingKeyCacheError) Error() string

type NegativeExpirationCacheError

type NegativeExpirationCacheError struct {
	// contains filtered or unexported fields
}

NegativeExpirationCacheError abstract class that implements negative expiration error

func (*NegativeExpirationCacheError) Error

func (err *NegativeExpirationCacheError) Error() string

type RedisCacheClient

type RedisCacheClient struct {
	// contains filtered or unexported fields
}

RedisCacheClient redis cache client implements ICacheClient. It wraps go-redis client - "github.com/go-redis/redis".

func NewRedisCacheClient

func NewRedisCacheClient(instrumentationProvider instrumentation.IInstrumentationProvider, redisBaseClient wrappers.IRedisBaseClientWrapper, retryPolicy retrypolicy.IRetryPolicy, cacheContext context.Context) *RedisCacheClient

NewRedisCacheClient is factory for RedisCacheClient

func (*RedisCacheClient) Get

func (client *RedisCacheClient) Get(key string) (string, error)

Get gets a value from the redis cache. It returns error when key does not exist.

func (*RedisCacheClient) Ping

func (client *RedisCacheClient) Ping() error

func (*RedisCacheClient) Set

func (client *RedisCacheClient) Set(key string, value string, expiration time.Duration) error

Set sets new item in the redis cache. Zero expiration means the key has no expiration time. It returns error when there was a problem trying to set the key. expiration must be non-negative expiration.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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