idmaker

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNodeID

func GetNodeID(nID int64) int64

func GetStep

func GetStep(nID int64) int64

func GetTime

func GetTime(nID int64) time.Time

func GetTimeString

func GetTimeString(nID int64) string

Types

type IDMaker

type IDMaker struct {
	// contains filtered or unexported fields
}

func NewIDMaker

func NewIDMaker(nodeid int64) *IDMaker

参数: nodeid范围[0, 2047], nodeid用于区分不同的ID生成器,确保不同的nodeid生成的ID也不相同

func (*IDMaker) FirstIDByUnixTime

func (t *IDMaker) FirstIDByUnixTime(nUnixTime int64) int64

查询某个时间点产生的最小ID可能值 通常用在数据库根据时间范围查询主键id的场景 参数: unix时间戳,秒。

func (*IDMaker) NextID

func (t *IDMaker) NextID() int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL