Documentation ¶
Index ¶
- Variables
- type MSetInput
- type MSetOutput
- type ScanOutput
- type Template
- func (t *Template) Del(ctx context.Context, keys ...any) error
- func (t *Template) Disconnect() error
- func (t *Template) Exists(ctx context.Context, key any) (bool, error)
- func (t *Template) Get(ctx context.Context, key, dest any) error
- func (t *Template) GetDel(ctx context.Context, key, dest any) error
- func (t *Template) Keys(ctx context.Context, pattern string) ([]string, error)
- func (t *Template) MSet(ctx context.Context, values ...MSetInput) []MSetOutput
- func (t *Template) Rename(ctx context.Context, key, newKey any) error
- func (t *Template) Scan(ctx context.Context, cursor uint64, match string, count int64) ScanOutput
- func (t *Template) Set(ctx context.Context, key, value any, opts ...*option.Set) error
- func (t *Template) SetGet(ctx context.Context, key, value, dest any, opts ...*option.Set) error
- func (t *Template) SimpleDisconnect()
- func (t *Template) SprintKey(vs ...any) string
Constants ¶
This section is empty.
Variables ¶
var ErrConvertKey = errors.New(MsgErrConvertKey)
var ErrConvertNewKey = errors.New(MsgErrConvertNewKey)
var ErrConvertValue = errors.New(MsgErrConvertValue)
var ErrDestIsNotPointer = errors.New(MsgErrDestIsNotPointer)
var ErrKeyNotFound = errors.New(MsgErrKeyNotFound)
var MsgErrConvertKey = "redis: error convert key to string"
var MsgErrConvertNewKey = "redis: error convert new key to string"
var MsgErrConvertValue = "redis: error convert value"
var MsgErrDestIsNotPointer = "redis: dest is not pointer"
var MsgErrKeyNotFound = "redis: key not found"
Functions ¶
This section is empty.
Types ¶
type MSetInput ¶
type MSetInput struct { // Key can be of any type, but cannot be null, and must be compatible with conversion to string (helper.ConvertToString). Key any // Value can be of any type, but cannot be null, and must be compatible with conversion to string (helper.ConvertToString). Value any // Opt to customize the operation (not required) Opt *option.Set }
type MSetOutput ¶
type ScanOutput ¶
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func NewTemplate ¶
NewTemplate create a new template instance
func (*Template) Del ¶
Del delete redis keys.
The keys parameter can be of any type, but cannot be empty, if an error occurs during the conversion, the error returned is ErrConvertKey.
If the return is null, the operation was performed successfully, otherwise an error occurred in the operation.
func (*Template) Disconnect ¶
Disconnect close connection to redis
func (*Template) Exists ¶
Exists redis values by key.
The key parameter can be of any type, but cannot be null, if an error occurs during the conversion, the error returned is ErrConvertKey.
The return if true means that the key exists, otherwise it returns false, and if an error occurs in the operation we return false with the second return parameter filled in
func (*Template) Get ¶
Get redis `GET key` command.
The key parameter can be of any type, but cannot be null, in case an error occurs when converting, the error returned is ErrConvertKey. If no registered key is found, the error ErrKeyNotFound is returned.
The dest parameter must be a pointer.
If the return is null, the operation was performed successfully, otherwise an error occurred in the operation.
func (*Template) GetDel ¶
GetDel get and delete value by key.
The key parameter can be of any type, but cannot be null, if an error occurs during the conversion, the error returned is ErrConvertKey. If no registered key is found, the error ErrKeyNotFound is returned.
The dest parameter must be a pointer.
If the return is null, the operation was performed successfully, otherwise an error occurred in the operation.
func (*Template) MSet ¶
func (t *Template) MSet(ctx context.Context, values ...MSetInput) []MSetOutput
MSet defines N values. (Multiple Set)
Parameter values cannot be empty, and must follow the Set function documentation for each MSetInput.
The return will have a list of MSetOutput with each key and the error // that occurred, if the MSetOutput.Err field is nil, it means that the operation for that key (MSetOutput.Key) was carried out successfully, otherwise it failed .
func (*Template) Rename ¶
Rename redis key.
The key and newKey parameters can be of any type, but cannot be null, in case an error occurs when converting the key or newKey, the error returned is ErrConvertKey or ErrConvertNewKey respectively.
If the return is null, the operation was performed successfully, otherwise an error occurred in the operation.
func (*Template) Set ¶
Set supports all options that the SET command supports.
The key and value parameters can be of any type, but cannot be nil, if an error occurs when converting the key or value, the error returned is ErrConvertKey or ErrConvertValue respectively.
If the return is nil, the operation was carried out successfully, otherwise an error occurred in the operation.
To customize the operation, use the opts parameter (option.Set).
func (*Template) SetGet ¶
SetGet supports all options that the SET command supports.
The key and value parameters can be of any type, but cannot be null, in case an error occurs when converting the key or value, the error returned is ErrConvertKey or ErrConvertValue respectively.
The dest parameter must be a pointer, not null, if we do not find a predecessor value to the set, dest will not have any modification
If the return is null, the operation was performed successfully, otherwise an error occurred in the operation.
To customize the operation, use the opts parameter (option.Set).
func (*Template) SimpleDisconnect ¶
func (t *Template) SimpleDisconnect()
SimpleDisconnect close connection to redis without error