data

package
v0.0.0-...-48e1cf4 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

package do stands for data options

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConcatedKeys

func ConcatedKeys(fields ...interface{}) string

Types

type Ctx

type Ctx[k comparable, v any] struct {
	Ctx             context.Context
	Rds             *redis.Client
	Key             string
	BloomFilterKeys *bloom.BloomFilter
}

func New

func New[k comparable, v any](ops ...*DataOption) *Ctx[k, v]

func (*Ctx[k, v]) AddBloomKey

func (db *Ctx[k, v]) AddBloomKey(key k) (err error)

func (*Ctx[k, v]) BLPop

func (db *Ctx[k, v]) BLPop(timeout time.Duration) (ret v, err error)

func (*Ctx[k, v]) BRPop

func (db *Ctx[k, v]) BRPop(timeout time.Duration) (ret v, err error)

func (*Ctx[k, v]) BRPopLPush

func (db *Ctx[k, v]) BRPopLPush(destination string, timeout time.Duration) (ret v, err error)

func (*Ctx[k, v]) BuildBloomFilterByKeys

func (db *Ctx[k, v]) BuildBloomFilterByKeys(keys []string, capacity int, falsePosition float64) (err error)

func (*Ctx[k, v]) BuildBloomFilterHKeys

func (db *Ctx[k, v]) BuildBloomFilterHKeys(capacity int, falsePosition float64) (err error)

func (*Ctx[k, v]) Concat

func (db *Ctx[k, v]) Concat(fields ...interface{}) *Ctx[k, v]

func (*Ctx[k, v]) Del

func (db *Ctx[k, v]) Del(key k) (err error)

for the reason of protection, both db.Key & Key are required. the avoid set Hash table to the wrong type , and thus leading to data loss.

func (*Ctx[k, v]) Get

func (db *Ctx[k, v]) Get(key k) (value v, err error)

func (*Ctx[k, v]) GetAll

func (db *Ctx[k, v]) GetAll(match string) (mapOut map[k]v, err error)

get all keys that match the pattern, and return a map of key->value

func (*Ctx[k, v]) HDel

func (db *Ctx[k, v]) HDel(fields ...k) (err error)

func (*Ctx[k, v]) HExists

func (db *Ctx[k, v]) HExists(field k) (ok bool, err error)

func (*Ctx[k, v]) HGet

func (db *Ctx[k, v]) HGet(field k) (value v, err error)

func (*Ctx[k, v]) HGetAll

func (db *Ctx[k, v]) HGetAll() (mapOut map[k]v, err error)

func (*Ctx[k, v]) HIncrBy

func (db *Ctx[k, v]) HIncrBy(field k, increment int64) (err error)

func (*Ctx[k, v]) HIncrByFloat

func (db *Ctx[k, v]) HIncrByFloat(field k, increment float64) (err error)

func (*Ctx[k, v]) HKeys

func (db *Ctx[k, v]) HKeys() (fields []k, err error)

func (*Ctx[k, v]) HLen

func (db *Ctx[k, v]) HLen() (length int64, err error)

func (*Ctx[k, v]) HMGET

func (db *Ctx[k, v]) HMGET(fields ...k) (values []v, err error)

func (*Ctx[k, v]) HRandField

func (db *Ctx[k, v]) HRandField(count int) (fields []k, err error)

func (*Ctx[k, v]) HSet

func (db *Ctx[k, v]) HSet(values ...interface{}) (err error)

HSet accepts values in following formats:

  • HSet("myhash", "key1", "value1", "key2", "value2")

  • HSet("myhash", map[string]interface{}{"key1": "value1", "key2": "value2"})

func (*Ctx[k, v]) HSetNX

func (db *Ctx[k, v]) HSetNX(field k, value v) (err error)

func (*Ctx[k, v]) HVals

func (db *Ctx[k, v]) HVals() (values []v, err error)

func (*Ctx[k, v]) Keys

func (db *Ctx[k, v]) Keys() (out []k, err error)

func (*Ctx[k, v]) LIndex

func (db *Ctx[k, v]) LIndex(index int64) (ret v, err error)

func (*Ctx[k, v]) LInsertAfter

func (db *Ctx[k, v]) LInsertAfter(pivot, param v) (err error)

func (*Ctx[k, v]) LInsertBefore

func (db *Ctx[k, v]) LInsertBefore(pivot, param v) (err error)

func (*Ctx[k, v]) LLen

func (db *Ctx[k, v]) LLen() (length int64, err error)

func (*Ctx[k, v]) LPop

func (db *Ctx[k, v]) LPop() (ret v, err error)

func (*Ctx[k, v]) LPush

func (db *Ctx[k, v]) LPush(param ...v) (err error)

func (*Ctx[k, v]) LRange

func (db *Ctx[k, v]) LRange(start, stop int64) (ret []v, err error)

func (*Ctx[k, v]) LRem

func (db *Ctx[k, v]) LRem(count int64, param v) (err error)

func (*Ctx[k, v]) LSet

func (db *Ctx[k, v]) LSet(index int64, param v) (err error)

func (*Ctx[k, v]) LTrim

func (db *Ctx[k, v]) LTrim(start, stop int64) (err error)

func (*Ctx[k, v]) RPop

func (db *Ctx[k, v]) RPop() (ret v, err error)

func (*Ctx[k, v]) RPush

func (db *Ctx[k, v]) RPush(param ...v) (err error)

func (*Ctx[k, v]) SAdd

func (db *Ctx[k, v]) SAdd(param v) (err error)

append to Set

func (*Ctx[k, v]) SIsMember

func (db *Ctx[k, v]) SIsMember(param v) (isMember bool, err error)

func (*Ctx[k, v]) SMembers

func (db *Ctx[k, v]) SMembers() (members []v, err error)

func (*Ctx[k, v]) SRem

func (db *Ctx[k, v]) SRem(param v) (err error)

func (*Ctx[k, v]) Scan

func (db *Ctx[k, v]) Scan(match string, cursor uint64, count int64) (keys []string, err error)

sacn key by pattern

func (*Ctx[k, v]) Set

func (db *Ctx[k, v]) Set(key k, param v, expiration time.Duration) (err error)

for the reason of protection, both db.Key & Key are required. the avoid set Hash table to the wrong type , and thus leading to data loss.

func (*Ctx[k, v]) SetAll

func (db *Ctx[k, v]) SetAll(_map map[k]v) (err error)

set each key value of _map to redis string type key value

func (*Ctx[k, v]) Sort

func (db *Ctx[k, v]) Sort(sort *redis.Sort) (ret []v, err error)

func (*Ctx[k, v]) TestHKey

func (db *Ctx[k, v]) TestHKey(key k) (exist bool)

func (*Ctx[k, v]) TestKey

func (db *Ctx[k, v]) TestKey(key k) (exist bool)

func (*Ctx[k, v]) Time

func (db *Ctx[k, v]) Time() (tm time.Time, err error)

func (*Ctx[k, v]) UnmarshalRedisZ

func (db *Ctx[k, v]) UnmarshalRedisZ(members []redis.Z) (out []v, scores []float64, err error)

func (*Ctx[k, v]) UnmarshalToSlice

func (db *Ctx[k, v]) UnmarshalToSlice(members []string) (out []v, err error)

func (*Ctx[k, v]) UpgradeSchema

func (db *Ctx[k, v]) UpgradeSchema(upgrader func(in v) (out v)) (err error)

func (*Ctx[k, v]) Y

func (db *Ctx[k, v]) Y(tm time.Time) *Ctx[k, v]

func (*Ctx[k, v]) YM

func (db *Ctx[k, v]) YM(tm time.Time) *Ctx[k, v]

func (*Ctx[k, v]) YMD

func (db *Ctx[k, v]) YMD(tm time.Time) *Ctx[k, v]

func (*Ctx[k, v]) YW

func (db *Ctx[k, v]) YW(tm time.Time) *Ctx[k, v]

func (*Ctx[k, v]) ZAdd

func (db *Ctx[k, v]) ZAdd(members ...redis.Z) (err error)

func (*Ctx[k, v]) ZCard

func (db *Ctx[k, v]) ZCard() (length int64, err error)

func (*Ctx[k, v]) ZCount

func (db *Ctx[k, v]) ZCount(min, max string) (length int64, err error)

func (*Ctx[k, v]) ZIncrBy

func (db *Ctx[k, v]) ZIncrBy(increment float64, member interface{}) (err error)

func (*Ctx[k, v]) ZLexCount

func (db *Ctx[k, v]) ZLexCount(min, max string) (length int64)

func (*Ctx[k, v]) ZPopMax

func (db *Ctx[k, v]) ZPopMax(count int64) (out []v, scores []float64, err error)

func (*Ctx[k, v]) ZPopMin

func (db *Ctx[k, v]) ZPopMin(count int64) (out []v, scores []float64, err error)

func (*Ctx[k, v]) ZRange

func (db *Ctx[k, v]) ZRange(start, stop int64) (members []v, err error)

func (*Ctx[k, v]) ZRangeByScore

func (db *Ctx[k, v]) ZRangeByScore(opt *redis.ZRangeBy) (out []v, err error)

func (*Ctx[k, v]) ZRangeByScoreWithScores

func (db *Ctx[k, v]) ZRangeByScoreWithScores(opt *redis.ZRangeBy) (out []v, scores []float64, err error)

func (*Ctx[k, v]) ZRangeWithScores

func (db *Ctx[k, v]) ZRangeWithScores(start, stop int64) (members []v, scores []float64, err error)

func (*Ctx[k, v]) ZRank

func (db *Ctx[k, v]) ZRank(member interface{}) (rank int64, err error)

func (*Ctx[k, v]) ZRem

func (db *Ctx[k, v]) ZRem(members ...interface{}) (err error)

func (*Ctx[k, v]) ZRemRangeByRank

func (db *Ctx[k, v]) ZRemRangeByRank(start, stop int64) (err error)

func (*Ctx[k, v]) ZRemRangeByScore

func (db *Ctx[k, v]) ZRemRangeByScore(min, max string) (err error)

func (*Ctx[k, v]) ZRevRange

func (db *Ctx[k, v]) ZRevRange(start, stop int64) (out []v, err error)

func (*Ctx[k, v]) ZRevRangeByScore

func (db *Ctx[k, v]) ZRevRangeByScore(opt *redis.ZRangeBy) (out []v, err error)

func (*Ctx[k, v]) ZRevRangeByScoreWithScores

func (db *Ctx[k, v]) ZRevRangeByScoreWithScores(opt *redis.ZRangeBy) (out []v, scores []float64, err error)

func (*Ctx[k, v]) ZRevRangeWithScores

func (db *Ctx[k, v]) ZRevRangeWithScores(start, stop int64) (members []v, scores []float64, err error)

func (*Ctx[k, v]) ZRevRank

func (db *Ctx[k, v]) ZRevRank(member interface{}) (rank int64, err error)

func (*Ctx[k, v]) ZScan

func (db *Ctx[k, v]) ZScan(cursor uint64, match string, count int64) ([]string, uint64, error)

func (*Ctx[k, v]) ZScore

func (db *Ctx[k, v]) ZScore(member interface{}) (score float64, err error)

type DataOption

type DataOption struct {
	Key        string
	DataSource string
}

DataOption is parameter to create an API, RPC, or CallAt

var Option *DataOption

func (*DataOption) WithDataSource

func (o *DataOption) WithDataSource(dataSource string) (out *DataOption)

func (*DataOption) WithKey

func (o *DataOption) WithKey(key string) (out *DataOption)

WithKey purpose of ApiNamed is to allow different API to have the same input type

Jump to

Keyboard shortcuts

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