cache

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetManager

func GetManager() *manager

GetManager - This function returns singleton instance of Cache Manager

func NewError

func NewError(err error) error

NewError - return a new instance of Error

func NewPingError

func NewPingError(err error) error

NewPingError - return a new instance of PingError

func NewReadError

func NewReadError(key string, err error) error

NewReadError - return a new instance of ReadError

func NewWriteError

func NewWriteError(key string, value any, err error) error

NewWriteError - return a new instance of WriteError

Types

type Error

type Error struct {
	Err error
}

Error object

func (*Error) Error

func (err *Error) Error() string

Error method - satisfying error interface

type ICache

type ICache interface {
	Ping(ctx context.Context) error
	Init(name string, configPrefix string, cachePrefix string) error
	IsInitialized() bool
	Close() error
	Get(ctx context.Context, key string, val any) error
	Set(ctx context.Context, key string, val any, expiration time.Duration) error
	SetStruct(ctx context.Context, key string, val any, expiration time.Duration) error
	GetStruct(ctx context.Context, key string, val any) error
	HSet(ctx context.Context, key string, expiration time.Duration, val ...any) error
	HGet(ctx context.Context, key string, field string, val any) error
}

ICache interface

type PingError

type PingError struct {
	Err error
}

PingError struct

func (*PingError) Error

func (err *PingError) Error() string

Error method - satisfying error interface

type ReadError

type ReadError struct {
	Key string
	Err error
}

ReadError struct

func (*ReadError) Error

func (err *ReadError) Error() string

Error method - satisfying error interface

type RedisClientCache

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

RedisClientCache object

func (*RedisClientCache) Close

func (ins *RedisClientCache) Close() error

Close - It closes the connection.

func (*RedisClientCache) Get

func (ins *RedisClientCache) Get(ctx context.Context, key string, val any) error

Get - get by key receiver

func (*RedisClientCache) GetStruct

func (ins *RedisClientCache) GetStruct(ctx context.Context, key string, val any) error

GetStruct - get the struct value by key

func (*RedisClientCache) HGet

func (ins *RedisClientCache) HGet(ctx context.Context, key string, field string, val any) error

func (*RedisClientCache) HSet

func (ins *RedisClientCache) HSet(ctx context.Context, key string, expiration time.Duration, val ...any) error

func (*RedisClientCache) Init

func (ins *RedisClientCache) Init(name string, configPrefix string, cachePrefix string) error

Init - Constructor: It reads the redis client configurations and initialize the connection

func (*RedisClientCache) IsInitialized

func (ins *RedisClientCache) IsInitialized() bool

IsInitialized receiver - that return boolean value

func (*RedisClientCache) Ping

func (ins *RedisClientCache) Ping(ctx context.Context) error

Ping - ping redis server

func (*RedisClientCache) Set

func (ins *RedisClientCache) Set(ctx context.Context, key string, val any, expiration time.Duration) error

Set - set by key and expiration receiver

func (*RedisClientCache) SetStruct

func (ins *RedisClientCache) SetStruct(ctx context.Context, key string, val any, expiration time.Duration) error

SetStruct - set the struct value by key

type WriteError

type WriteError struct {
	Key   string
	Value any
	Err   error
}

WriteError struct

func (*WriteError) Error

func (err *WriteError) Error() string

Error method - satisfying error interface

Jump to

Keyboard shortcuts

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