chore: replace all cn comments to en version by volc api (#313)

This commit is contained in:
tecvan
2025-07-31 15:18:11 +08:00
committed by GitHub
parent 91d6cdb430
commit 5abc63fba6
254 changed files with 5899 additions and 5844 deletions

View File

@@ -34,7 +34,7 @@ const (
type IDGenerator = idgen.IDGenerator
func New(client *redis.Client) (idgen.IDGenerator, error) {
// 初始化代码。
// Initialization code.
return &idGenImpl{
cli: client,
}, nil
@@ -60,7 +60,7 @@ func (i *idGenImpl) GenMultiIDs(ctx context.Context, counts int) ([]int64, error
leftNum := int64(counts)
lastMs := int64(0)
ids := make([]int64, 0, counts)
svrID := int64(0) // 一个 server id 全部是 0
svrID := int64(0) // A server id is all 0.
for idx := int64(0); leftNum > 0 && idx < maxTimeAddrTimes; idx++ {
ms := maxInt64(i.GetIDTimeMs(), lastMs)
@@ -131,12 +131,12 @@ func (i *idGenImpl) GetIDTimeMs() int64 {
}
func (i *idGenImpl) Expire(ctx context.Context, key string) {
// 暂时忽略错误
// Temporarily ignore errors
_, _ = i.cli.Expire(ctx, key, counterKeyExpirationTime).Result()
}
func genIDKey(space string, svrID int64, ms int64) string {
// 此 Key 的格式一旦确定,便不能再变化
// Once the format of this key is determined, it cannot be changed
return fmt.Sprintf("id_generator:%v:%v:%v", space, svrID, ms)
}