Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNil = redis.Nil ErrZAddKVLengthNotMatch = errors.New("ERR_ZADD_KV_LENGTH_NOT_MATCH") )
View Source
var ( ErrCanNotMarshalAsProtobufMessage = errors.New("ErrCanNotMarshalAsProtobufMessage") ErrCanNotUnmarshalAsProtobufMessage = errors.New("ErrCanNotUnmarshalAsProtobufMessage") )
View Source
var ( // ErrConfigNotFound is returned when gredis config can not be found ErrConfigNotFound = errors.New("can not find gredis config") // ErrTTLKeyNotExpireSet is returned when ttl key exists but has no associated expire ErrTTLKeyNotExpireSet = errors.New("ttl key exists but has no associated expire") // ErrTTLKeyNotExist is returned when ttl key not exist ErrTTLKeyNotExist = errors.New("ttl key not exist") ErrRedisConfigNotFound = errors.New("can not find gredis config") )
Functions ¶
Types ¶
type JsonMarshaller ¶
type JsonMarshaller struct{}
func (*JsonMarshaller) Marshal ¶
func (jm *JsonMarshaller) Marshal(v interface{}) ([]byte, error)
func (*JsonMarshaller) Unmarshal ¶
func (jm *JsonMarshaller) Unmarshal(data []byte, v interface{}) error
type ObjMarshaller ¶
type ProtoMarshaller ¶
type ProtoMarshaller struct{}
func (*ProtoMarshaller) Marshal ¶
func (pm *ProtoMarshaller) Marshal(v interface{}) ([]byte, error)
func (*ProtoMarshaller) Unmarshal ¶
func (pm *ProtoMarshaller) Unmarshal(data []byte, v interface{}) error
type RedisClient ¶
RedisClient introduce all the gredis method we need for gredis bot and also with context support
func NewRedisClient ¶
func NewRedisClient(option *RedisClientOption) (RedisClient, error)
NewRedisClient create a redisClient object from config it will create bot connect to single, ring or cluster based on the configuration currently we only support redisClient, may add more in the future (for example , v9Client?), so we return an interface
func NewRedisClientByConfig ¶
func NewRedisClientByConfig(cfg env.ModuleConfig, redisDBKey string) (RedisClient, error)
type RedisClientOption ¶
type RedisClientOption struct {
Mode Mode
Addr string
Password string
Db int
PoolSize int
Addrs map[string]string
ClusterAddrs []string
ClusterMaxRedirects int
ClusterReadOnly bool
DialTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
Marshaller ObjMarshaller
}
RedisClientOption gredis bot option
type SelfMarshaller ¶
type String ¶
type String interface {
SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)
Set(ctx context.Context, key string, value interface{}) error
SetEx(ctx context.Context, key string, value interface{}, expiration time.Duration) error
Get(ctx context.Context, key string) (string, error)
Incr(ctx context.Context, key string) (int64, error)
IncrBy(ctx context.Context, key string, value int64) (int64, error)
}
Click to show internal directories.
Click to hide internal directories.