sole

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get() int64

Get 获取全局唯一标识符

func GetWith

func GetWith(name any) int64

GetWith 获取特定命名空间的唯一标识符

func RegNameSpace added in v0.0.20

func RegNameSpace(name any)

RegNameSpace 注册特定命名空间的唯一标识符

func Reset added in v0.0.20

func Reset()

Reset 重置全局唯一标识符

func ResetWith added in v0.0.20

func ResetWith(name any)

ResetWith 重置特定命名空间的唯一标识符

func SonyflakeID

func SonyflakeID() int64

SonyflakeID 获取一个雪花id

func SonyflakeIDE

func SonyflakeIDE() (int64, error)

SonyflakeIDE 获取一个雪花id

func SonyflakeSetting

func SonyflakeSetting(settings sonyflake.Settings)

SonyflakeSetting 配置雪花id生成策略

func UnRegNameSpace added in v0.0.20

func UnRegNameSpace(name any)

UnRegNameSpace 解除注销特定命名空间的唯一标识符

Types

type Once added in v0.0.27

type Once[V any] struct {
	// contains filtered or unexported fields
}

Once 用于数据取值去重的结构体

func NewOnce added in v0.0.27

func NewOnce[V any]() *Once[V]

NewOnce 创建一个用于数据取值去重的结构实例

func (*Once[V]) Get added in v0.0.27

func (slf *Once[V]) Get(key any, value V, defaultValue V) V

Get 获取一个值,当该值已经被获取过的时候,返回 defaultValue,否则返回 value

func (*Once[V]) Reset added in v0.0.27

func (slf *Once[V]) Reset(key ...any)

Reset 当 key 数量大于 0 时,将会重置对应 key 的记录,否则重置所有记录

Jump to

Keyboard shortcuts

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