Documentation ¶
Index ¶
- Variables
- func GetLoaclIp() string
- func Ipv4StringToInt(ip string) int64
- type Cache
- func (c Cache) BindDeleteCallBackFunc(f func(string, interface{}))
- func (c Cache) Del(k string)
- func (c Cache) Exists(k string) bool
- func (c Cache) Get(k string) (interface{}, bool)
- func (c Cache) GetEx(k string) (interface{}, time.Time, bool)
- func (c Cache) HDel(key string, fields ...string)
- func (c Cache) HExists(key string, fields ...string) bool
- func (c Cache) HGet(key string, fields ...string) map[string]interface{}
- func (c Cache) HGetAll(key string) map[string]interface{}
- func (c Cache) HKeys(key string) []string
- func (c Cache) HMSet(key string, data map[string]interface{})
- func (c Cache) HSet(key, field string, val interface{})
- func (c Cache) HSetEx(key string, d time.Duration, callBack bool) bool
- func (c Cache) HSetNx(key, field string, val interface{}) bool
- func (c Cache) HVAls(key string) []interface{}
- func (c Cache) ItemCount() int
- func (c Cache) Items() map[string]interface{}
- func (c Cache) SAdd(key string, d time.Duration, callBack bool, members ...interface{})
- func (c Cache) SCard(key string) int
- func (c Cache) SISMembers(key string, member interface{}) bool
- func (c Cache) SMembers(key string) []interface{}
- func (c Cache) SRem(key string, members ...interface{}) int
- func (c Cache) Set(k string, v interface{}, d time.Duration, callBack bool)
- func (c Cache) SetNx(k string, v interface{}, d time.Duration, callBack bool) bool
- func (c Cache) Stop()
- type HASHItem
- type ID
- func ParseBase2(id string) (ID, error)
- func ParseBase32(b []byte) (ID, error)
- func ParseBase36(id string) (ID, error)
- func ParseBase58(b []byte) (ID, error)
- func ParseBase64(id string) (ID, error)
- func ParseBytes(id []byte) (ID, error)
- func ParseInt64(id int64) ID
- func ParseIntBytes(id [8]byte) ID
- func ParseString(id string) (ID, error)
- func (f ID) Base2() string
- func (f ID) Base32() string
- func (f ID) Base36() string
- func (f ID) Base58() string
- func (f ID) Base64() string
- func (f ID) Bytes() []byte
- func (f ID) Int64() int64
- func (f ID) IntBytes() [8]byte
- func (f ID) MarshalJSON() ([]byte, error)
- func (f ID) Node() int64
- func (f ID) Step() int64
- func (f ID) String() string
- func (f ID) Time() int64
- func (f *ID) UnmarshalJSON(b []byte) error
- type JSONSyntaxError
- type Job
- type KVItem
- type Node
- type Set
- type SetItem
- type Task
- type TimeWheel
Constants ¶
This section is empty.
Variables ¶
var ( // Epoch is set to the twitter snowflake epoch of Nov 04 2010 01:42:54 UTC in milliseconds // You may customize this to set a different epoch for your application. Epoch int64 = 1288834974657 // NodeBits holds the number of bits to use for Node // Remember, you have a total 22 bits to share between Node/Step NodeBits uint8 = 10 // StepBits holds the number of bits to use for Step // Remember, you have a total 22 bits to share between Node/Step StepBits uint8 = 12 )
var ErrInvalidBase32 = errors.New("invalid base32")
ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte
var ErrInvalidBase58 = errors.New("invalid base58")
ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte
Functions ¶
func GetLoaclIp ¶
func GetLoaclIp() string
func Ipv4StringToInt ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (Cache) BindDeleteCallBackFunc ¶
func (c Cache) BindDeleteCallBackFunc(f func(string, interface{}))
func (Cache) SISMembers ¶
type ID ¶
type ID int64
An ID is a custom type used for a snowflake ID. This is used so we can attach methods onto the ID.
func ParseBase2 ¶
ParseBase2 converts a Base2 string into a snowflake ID
func ParseBase32 ¶
ParseBase32 parses a base32 []byte into a snowflake ID NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func ParseBase36 ¶
ParseBase36 converts a Base36 string into a snowflake ID
func ParseBase58 ¶
ParseBase58 parses a base58 []byte into a snowflake ID
func ParseBase64 ¶
ParseBase64 converts a base64 string into a snowflake ID
func ParseBytes ¶
ParseBytes converts a byte slice into a snowflake ID
func ParseIntBytes ¶
ParseIntBytes converts an array of bytes encoded as big endian integer as a snowflake ID
func ParseString ¶
ParseString converts a string into a snowflake ID
func (ID) Base32 ¶
Base32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.
func (ID) IntBytes ¶
IntBytes returns an array of bytes of the snowflake ID, encoded as a big endian integer.
func (ID) MarshalJSON ¶
MarshalJSON returns a json byte array string of the snowflake ID.
func (ID) Node ¶
Node returns an int64 of the snowflake ID node number DEPRECATED: the below function will be removed in a future release.
func (ID) Step ¶
Step returns an int64 of the snowflake step (or sequence) number DEPRECATED: the below function will be removed in a future release.
func (ID) Time ¶
Time returns an int64 unix timestamp in milliseconds of the snowflake ID time DEPRECATED: the below function will be removed in a future release.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON converts a json byte array of a snowflake ID into an ID type.
type JSONSyntaxError ¶
type JSONSyntaxError struct {
// contains filtered or unexported fields
}
A JSONSyntaxError is returned from UnmarshalJSON if an invalid ID is provided.
func (JSONSyntaxError) Error ¶
func (j JSONSyntaxError) Error() string
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
A Node struct holds the basic information needed for a snowflake generator node
type TimeWheel ¶
type TimeWheel struct { C chan interface{} //时间轮通知通道 // contains filtered or unexported fields }
TimeWheel 时间轮
func (*TimeWheel) RemoveTimer ¶
func (tw *TimeWheel) RemoveTimer(key interface{})
RemoveTimer 删除定时器 key为添加定时器时传递的定时器唯一标识