cacher

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheKey

type CacheKey string

func NewCacheKey

func NewCacheKey(key string) CacheKey

NewCacheKey creates a new CacheKey with the given key.

func (CacheKey) Enrich

func (c CacheKey) Enrich(value string) string

Enrich enriches the cache key with the given value.

func (CacheKey) String

func (c CacheKey) String() string

String returns the string representation of the cache key.

type Client

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

func New

func New(opts ...Option) (*Client, error)

func (*Client) DeleteFromCache

func (s *Client) DeleteFromCache(ctx context.Context, key string) error

DeleteFromCache deletes a value from the cache

func (*Client) GetFromCache

func (s *Client) GetFromCache(ctx context.Context, key string) ([]byte, error)

GetFromCache reads a value from the cache

func (*Client) GetManyFromCache

func (s *Client) GetManyFromCache(ctx context.Context, keys []string) ([][]byte, error)

GetManyFromCache retrieves multiple values from the cache based on the provided keys. It returns a slice of byte slices representing the retrieved values, or an error if any occurred.

func (*Client) Validate

func (c *Client) Validate() error

Validate validates the cacher

func (*Client) WriteAnyToCache

func (s *Client) WriteAnyToCache(ctx context.Context, key string, value interface{}) error

WriteAnyToCache writes the given value to the cache using the specified key. The value is first marshaled into JSON format before being written to the cache. If an error occurs during marshaling or writing to the cache, it is returned.

func (*Client) WriteManyToCache

func (s *Client) WriteManyToCache(ctx context.Context, pairs map[string][]byte) error

WriteManyToCache writes many values to the cache

func (*Client) WriteToCache

func (s *Client) WriteToCache(ctx context.Context, key string, value []byte) error

WriteToCache writes a value to the cache

func (*Client) WriteToCacheWithTTL added in v1.20.0

func (s *Client) WriteToCacheWithTTL(ctx context.Context, key string, value []byte, timeToLiveInSeconds int) error

WriteToCacheWithTTL writes a value to the cache with a defined ttl in seconds

type Option

type Option func(*Client)

func WithCacheTTLInSeconds

func WithCacheTTLInSeconds(ttl int) Option

WithCacheTTLInSeconds configures the cache TTL in seconds

func WithIntrumentationClient

func WithIntrumentationClient(client *instrumentation.Client) Option

WithIntrumentationClient configures whether or not instrumentation is enabled

func WithLogger

func WithLogger(logger *zap.Logger) Option

WithLogger configures the logger

func WithRedisConn

func WithRedisConn(connPool *redis.Pool) Option

WithRedisConn configures the redis connection

func WithServiceName

func WithServiceName(name string) Option

WithServiceName configures the service name

Jump to

Keyboard shortcuts

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