dbs

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Byte2Ints added in v0.3.20

func Byte2Ints[T constraints.Integer](n T, b byte) []T

Byte2Ints 字节码转换整数. nolint

func DecodeID

func DecodeID(id uint64) (uint64, uint64, uint64)

DecodeID id解码.

func ID

func ID() uint64

ID 获取ID.

Example
package main

import (
	"fmt"

	"github.com/xuender/oils/dbs"
)

func main() {
	fmt.Println(dbs.ID())
	fmt.Println(dbs.ID())
}
Output:

func Int2Byte added in v0.3.20

func Int2Byte[T constraints.Integer](i T) (T, byte)

Int2Byte 整数转换字节码.

func NewID

func NewID(num uint64) uint64

NewID 新建ID. num 4位 16个. 起始日期 2021-10-31 日. 合计53位,js中使用不会出错.

Example
package main

import (
	"fmt"

	"github.com/xuender/oils/dbs"
)

func main() {
	fmt.Println(dbs.NewID(3))
	id := dbs.ID()
	fmt.Println(id)
	fmt.Println(dbs.DecodeID(id))
}
Output:

func Rand

func Rand() uint64

Rand 随机数,兼容JS数值长度.

Example
package main

import (
	"fmt"

	"github.com/xuender/oils/dbs"
)

func main() {
	fmt.Println(dbs.Rand())
}
Output:

Types

type BitMap added in v0.3.20

type BitMap[T constraints.Integer] []byte

BitMap 位图.

Example
package main

import (
	"fmt"

	"github.com/xuender/oils/dbs"
)

func main() {
	tag := dbs.NewBitMap(1, 2, 33)

	fmt.Println(tag.Has(1))
	fmt.Println(tag.Has(3))
	fmt.Println(tag.Has(33))
	fmt.Println(tag)

}
Output:

true
false
true
1, 2, 33

func Intersection added in v0.3.20

func Intersection[T constraints.Integer](elems ...BitMap[T]) BitMap[T]

Intersection 交集. nolint

func NewBitMap added in v0.3.20

func NewBitMap[T constraints.Integer](elems ...T) BitMap[T]

NewBitMap 新建位图.

func (*BitMap[T]) Add added in v0.3.20

func (t *BitMap[T]) Add(elems ...T) BitMap[T]

Add 增加位图.

func (*BitMap[T]) AddBitMap added in v0.3.20

func (t *BitMap[T]) AddBitMap(elem BitMap[T]) BitMap[T]

AddBitMap 增加位图.

func (BitMap[T]) All added in v0.3.20

func (t BitMap[T]) All(elems ...T) bool

All 全部包含.

func (BitMap[T]) Any added in v0.3.20

func (t BitMap[T]) Any(elems ...T) bool

Any 包含任意.

func (BitMap[T]) Bytes added in v0.3.20

func (t BitMap[T]) Bytes() []byte

Bytes 字节码.

func (BitMap[T]) Count added in v0.3.20

func (t BitMap[T]) Count() int

Count 位图数量.

func (BitMap[T]) Del added in v0.3.20

func (t BitMap[T]) Del(elems ...T) BitMap[T]

Del 删除位图.

func (BitMap[T]) DelBitMap added in v0.3.20

func (t BitMap[T]) DelBitMap(elem BitMap[T]) BitMap[T]

DelBitMap 删除位图.

func (BitMap[T]) Has added in v0.3.20

func (t BitMap[T]) Has(tag T) bool

Has 包含位图.

func (BitMap[T]) Join added in v0.3.20

func (t BitMap[T]) Join(sep string) string

Join 集合连接.

func (*BitMap[T]) Load added in v0.3.20

func (t *BitMap[T]) Load(bs []byte)

Load 加载.

func (BitMap[T]) Slice added in v0.3.20

func (t BitMap[T]) Slice() []T

Slice 转换切片.

func (BitMap[T]) String added in v0.3.20

func (t BitMap[T]) String() string

String 字符串.

Directories

Path Synopsis
Package cache 简单的内存缓存.
Package cache 简单的内存缓存.
Package gorms 数据库操作.
Package gorms 数据库操作.

Jump to

Keyboard shortcuts

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