1 Star 0 Fork 0

GarlicBoris/gozero-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
no_generator.go 363 Bytes
一键复制 编辑 原始数据 按行查看 历史
yanwc 提交于 10个月前 . feat: 增加编号生成器
package utils
import (
"strconv"
"time"
"github.com/zeromicro/go-zero/core/stores/redis"
)
func GenerateNo(redis *redis.Redis, prefix string) (string, error) {
v := time.Now().UnixNano()
key := prefix + strconv.Itoa(int(v))
no, err := redis.Incr(key)
if err != nil {
return "", err
}
redis.Expire(key, 5)
return key + strconv.Itoa(int(no)), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/yanwc/gozero-utils.git
git@gitee.com:yanwc/gozero-utils.git
yanwc
gozero-utils
gozero-utils
v1.0.15

搜索帮助