Documentation ¶
Index ¶
- Variables
- func IsErrFailedCommand(err error) bool
- func IsErrNoCache(err error) bool
- type Connection
- func (c *Connection) Close() error
- func (c *Connection) DeleteCache(ctx context.Context, key string) error
- func (c *Connection) DeleteCacheByPrefix(ctx context.Context, prefix string) error
- func (c *Connection) GetCache(ctx context.Context, key string, value interface{}) error
- func (c *Connection) LogError(err error, msg string)
- func (c *Connection) LogWarn(err error, msg string)
- func (c *Connection) SetCache(ctx context.Context, key string, value interface{}, ttl time.Duration) error
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoCache represents a "Cache not found" error. ErrNoCache = errors.New("Cache not found") // ErrFailedCommand represents a "Failed command" error. ErrFailedCommand = errors.New("Failed command") )
View Source
var (
DefaultCacheTTL = 24 * time.Hour
)
Functions ¶
func IsErrFailedCommand ¶
IsErrFailedCommand checks if the given error is a "Failed command" error.
func IsErrNoCache ¶
IsErrNoCache checks if the given error is a "Cache not found" error.
Types ¶
type Connection ¶
type Connection struct { Client *redisv8.Client DebugMode bool // contains filtered or unexported fields }
Connection stores Redis connection client & information.
func NewConnection ¶
func NewConnection(conf RedisConfig) (*Connection, error)
NewConnection creates new basic Redis connection.
func (*Connection) Close ¶
func (c *Connection) Close() error
Close closes the client, releasing any open resources.
func (*Connection) DeleteCache ¶
func (c *Connection) DeleteCache(ctx context.Context, key string) error
DeleteCache deletes a single cache with the specified key.
func (*Connection) DeleteCacheByPrefix ¶
func (c *Connection) DeleteCacheByPrefix(ctx context.Context, prefix string) error
DeleteCacheByPrefix deletes multiple caches that matched the given prefix key.
func (*Connection) GetCache ¶
func (c *Connection) GetCache(ctx context.Context, key string, value interface{}) error
GetCache gets cache for the specified key and assign the result to value.
func (*Connection) LogError ¶
func (c *Connection) LogError(err error, msg string)
LogError prints Redis connection error log to stderr.
func (*Connection) LogWarn ¶
func (c *Connection) LogWarn(err error, msg string)
LogWarn prints Redis connection warning log to stdout.
Click to show internal directories.
Click to hide internal directories.