This website works better with JavaScript.
Home
Issues
Pull Requests
Milestones
AI流水线
Repositories
Datasets
Forum
实训
竞赛
大数据
Register
Sign In
hummingbird
/
idgenerator
Not watched
Unwatch
Watch all
Watch but not notify
2
Star
0
Fork
0
Code
Releases
6
Wiki
Activity
Issues
5
Pull Requests
0
Datasets
Model
Cloudbrain
Browse Source
Merge pull request
#26
from yesgs/master
添加从ID解析生成时间的方法
tags/v1.3.1
yitter
GitHub
2 years ago
parent
ada921034b
9afbb33640
commit
0e6fbe732f
No known key found for this signature in database
GPG Key ID:
4AEE18F83AFDEB23
2 changed files
with
9 additions
and
0 deletions
Split View
Diff Options
Show Stats
Download Patch File
Download Diff File
+4
-0
Go/source/idgen/DefaultIdGenerator.go
+5
-0
Go/source/idgen/YitIdHelper.go
+ 4
- 0
Go/source/idgen/DefaultIdGenerator.go
View File
@@ -87,3 +87,7 @@ func NewDefaultIdGenerator(options *IdGeneratorOptions) *DefaultIdGenerator {
func (dig DefaultIdGenerator) NewLong() int64 {
return dig.SnowWorker.NextId()
}
func (dig DefaultIdGenerator) ExtractTime(id int64) time.Time {
return time.UnixMilli(id>>(dig.Options.WorkerIdBitLength+dig.Options.SeqBitLength) + dig.Options.BaseTime)
}
+ 5
- 0
Go/source/idgen/YitIdHelper.go
View File
@@ -2,6 +2,7 @@ package idgen
import (
"sync"
"time"
)
var singletonMutex sync.Mutex
@@ -27,3 +28,7 @@ func NextId() int64 {
return idGenerator.NewLong()
}
func ExtractTime(id int64) time.Time {
return idGenerator.ExtractTime(id)
}
Write
Preview
Loading…
Cancel
Save