Documentation ¶
Index ¶
- func DelAll(client *redis.Client, pattern string) (tot, del int, err error)
- func SetAll(client *redis.Client, keys, values []string) (tot, add int, err error)
- func SetExAll(client *redis.Client, keys, values []string, expirations []int64) (tot, add int, err error)
- type ILogger
- type LoggerLogger
- func (l *LoggerLogger) AfterProcess(ctx context.Context, cmd redis.Cmder) error
- func (l *LoggerLogger) AfterProcessPipeline(context.Context, []redis.Cmder) error
- func (l *LoggerLogger) BeforeProcess(ctx context.Context, _ redis.Cmder) (context.Context, error)
- func (l *LoggerLogger) BeforeProcessPipeline(ctx context.Context, _ []redis.Cmder) (context.Context, error)
- type LogrusLogger
- func (l *LogrusLogger) AfterProcess(ctx context.Context, cmd redis.Cmder) error
- func (l *LogrusLogger) AfterProcessPipeline(context.Context, []redis.Cmder) error
- func (l *LogrusLogger) BeforeProcess(ctx context.Context, _ redis.Cmder) (context.Context, error)
- func (l *LogrusLogger) BeforeProcessPipeline(ctx context.Context, _ []redis.Cmder) (context.Context, error)
- type SilenceLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelAll ¶
DelAll deletes all keys from given pattern (KEYS -> DEL). This is an atomic operator and return err when failed.
func SetAll ¶
SetAll sets all given key-value pairs (SET -> SET -> ...). This is a non-atomic operator, that means if there is a value failed to set, no rollback will be done, and it will return the current added count and error value.
func SetExAll ¶
func SetExAll(client *redis.Client, keys, values []string, expirations []int64) (tot, add int, err error)
SetExAll sets all given key-value-expiration pairs (SET -> SET -> ...), equals to SetAll with expiration in second. This is a non-atomic operator, that means if there is a value failed to set, no rollback will be done, and it will return the current added count and error value.
Types ¶
type LoggerLogger ¶
type LoggerLogger struct {
// contains filtered or unexported fields
}
LoggerLogger represents a redis's logger (as redis.Hook), used to log redis command executing message to logrus.StdLogger.
func NewLoggerLogger ¶
func NewLoggerLogger(logger logrus.StdLogger) *LoggerLogger
NewLoggerLogger creates a new LoggerLogger using given logrus.StdLogger. Example:
client := redis.NewClient(options) redis.SetLogger(NewSilenceLogger()) l := log.New(os.Stderr, "", log.LstdFlags) client.AddHook(xredis.NewLoggerLogger(l))
func (*LoggerLogger) AfterProcess ¶
func (l *LoggerLogger) AfterProcess(ctx context.Context, cmd redis.Cmder) error
AfterProcess logs to logrus.StdLogger.
func (*LoggerLogger) AfterProcessPipeline ¶
func (l *LoggerLogger) AfterProcessPipeline(context.Context, []redis.Cmder) error
func (*LoggerLogger) BeforeProcess ¶
BeforeProcess saves start time to context, used in AfterProcess.
func (*LoggerLogger) BeforeProcessPipeline ¶
type LogrusLogger ¶
type LogrusLogger struct {
// contains filtered or unexported fields
}
LogrusLogger represents a redis's logger (as redis.Hook), used to log redis command executing message to logrus.Logger.
func NewLogrusLogger ¶
func NewLogrusLogger(logger *logrus.Logger) *LogrusLogger
NewLogrusLogger creates a new LogrusLogger using given logrus.Logger. Example:
client := redis.NewClient(options) redis.SetLogger(NewSilenceLogger()) l := logrus.New() l.SetFormatter(&logrus.TextFormatter{}) client.AddHook(xredis.NewLogrusLogger(l))
func (*LogrusLogger) AfterProcess ¶
func (l *LogrusLogger) AfterProcess(ctx context.Context, cmd redis.Cmder) error
AfterProcess logs to logrus.Logger.
func (*LogrusLogger) AfterProcessPipeline ¶
func (l *LogrusLogger) AfterProcessPipeline(context.Context, []redis.Cmder) error
func (*LogrusLogger) BeforeProcess ¶
BeforeProcess saves start time to context, used in AfterProcess.
func (*LogrusLogger) BeforeProcessPipeline ¶
type SilenceLogger ¶
type SilenceLogger struct{}
SilenceLogger represents a redis's logger, used to hide go-redis's info logger.
func NewSilenceLogger ¶
func NewSilenceLogger() *SilenceLogger
NewSilenceLogger creates a new SilenceLogger. Example:
client := redis.NewClient(options) redis.SetLogger(xredis.NewSilenceLogger())