resources

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CacheSkill = "github.com/eolinker/apinto/resources.resources.ICache"
View Source
const VectorsSkill = "github.com/eolinker/apinto/resources.resources.IVectors"

通过滑动窗口实现的平滑计数器

Variables

View Source
var (
	LocalCache func() ICache
)
View Source
var (
	LocalVector func() IVectors
)

Functions

func NewArrayInterfaceResult added in v0.15.11

func NewArrayInterfaceResult(val []interface{}, err error) *arrayInterfaceResult

func NewBoolResult added in v0.9.0

func NewBoolResult(val bool, err error) *boolResult

func NewIntResult added in v0.9.0

func NewIntResult(val int64, err error) *intResult

func NewInterfaceResult added in v0.14.9

func NewInterfaceResult(val interface{}, err error) *interfaceResult

func NewStatusResult added in v0.9.0

func NewStatusResult(err error) *statusResult

func NewStringResult added in v0.9.0

func NewStringResult(val string, err error) *stringResult

func NewStringResultBytes added in v0.9.0

func NewStringResultBytes(value []byte, err error) *stringResult

func NewStringSliceResult added in v0.15.11

func NewStringSliceResult(val []string, err error) *stringSliceResult

func ToBytes added in v0.9.0

func ToBytes(v int64) []byte

func ToInt added in v0.9.0

func ToInt(b []byte) int64

Types

type ArrayInterfaceResult added in v0.15.11

type ArrayInterfaceResult interface {
	Result() ([]interface{}, error)
}

type BoolResult added in v0.9.0

type BoolResult interface {
	Result() (bool, error)
}

type ICache

type ICache interface {
	Set(ctx context.Context, key string, value []byte, expiration time.Duration) StatusResult
	SetNX(ctx context.Context, key string, value []byte, expiration time.Duration) BoolResult
	DecrBy(ctx context.Context, key string, decrement int64, expiration time.Duration) IntResult
	IncrBy(ctx context.Context, key string, decrement int64, expiration time.Duration) IntResult
	Keys(ctx context.Context, key string) StringSliceResult
	Get(ctx context.Context, key string) StringResult
	GetDel(ctx context.Context, key string) StringResult
	HMSetN(ctx context.Context, key string, fields map[string]interface{}, expiration time.Duration) BoolResult
	HMGet(ctx context.Context, key string, fields ...string) ArrayInterfaceResult
	Del(ctx context.Context, keys ...string) IntResult
	Run(ctx context.Context, script interface{}, keys []string, args ...interface{}) InterfaceResult
	Tx() TX
}

type IVectors added in v0.9.0

type IVectors interface {
	BuildVector(name string, uni, step time.Duration) (Vector, error)
}

type IntResult added in v0.9.0

type IntResult interface {
	Result() (int64, error)
}

type InterfaceResult added in v0.14.9

type InterfaceResult interface {
	Result() (interface{}, error)
}

type Metrics added in v0.9.0

type Metrics interface {
	Send(labels map[string]string, fields map[string]interface{})
}

type StatusResult added in v0.9.0

type StatusResult interface {
	Result() error
}

type StringResult added in v0.9.0

type StringResult interface {
	Result() (string, error)
	Bytes() ([]byte, error)
}

type StringSliceResult added in v0.15.11

type StringSliceResult interface {
	Result() ([]string, error)
}

type TX added in v0.9.0

type TX interface {
	ICache
	Exec(ctx context.Context) error
}

type Vector added in v0.9.0

type Vector interface {
	Add(key string, delta int64)
	CompareAndAdd(key string, threshold, delta int64) bool
	Get(key string) int64
}

type VectorsLocalBuild added in v0.9.0

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

func NewVectorsLocalBuild added in v0.9.0

func NewVectorsLocalBuild() *VectorsLocalBuild

func (*VectorsLocalBuild) BuildVector added in v0.9.0

func (v *VectorsLocalBuild) BuildVector(name string, uni, step time.Duration) (Vector, error)

Jump to

Keyboard shortcuts

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