add del func of redis string type

This commit is contained in:
douxu 2025-08-21 17:04:10 +08:00
parent 3fa0a8c6ca
commit f8f83c38d9
3 changed files with 20 additions and 1 deletions

View File

@ -95,3 +95,20 @@ func (rs *RedisString) IncrBy(stringKey string, value int64) error {
} }
return nil return nil
} }
// GETDEL define func of get the value of key and delete the key
func (rs *RedisString) GETDEL(stringKey string) error {
err := rs.rwLocker.WLock(rs.ctx)
if err != nil {
logger.Error(rs.ctx, "lock wLock by stringKey failed", "string_key", stringKey, "error", err)
return err
}
defer rs.rwLocker.UnWLock(rs.ctx)
err = rs.storageClient.GetDel(rs.ctx, stringKey).Err()
if err != nil {
logger.Error(rs.ctx, "del the key failed", "string_key", stringKey, "error", err)
return err
}
return nil
}

2
go.mod
View File

@ -1,6 +1,6 @@
module modelRT module modelRT
go 1.22.5 go 1.24.1
require ( require (
github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/DATA-DOG/go-sqlmock v1.5.2

View File

@ -1,3 +1,4 @@
// Package network define struct of network operation
package network package network
import ( import (
@ -6,6 +7,7 @@ import (
"modelRT/orm" "modelRT/orm"
) )
// ConvertAnyComponentInfosToComponents define convert any component request info to component struct
func ConvertAnyComponentInfosToComponents(anyInfo interface{}) (*orm.Component, error) { func ConvertAnyComponentInfosToComponents(anyInfo interface{}) (*orm.Component, error) {
switch info := anyInfo.(type) { switch info := anyInfo.(type) {
case ComponentCreateInfo: case ComponentCreateInfo: