nosql

package module
v0.0.0-...-c774380 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 11 Imported by: 9

README

nosql

nosql client and cache

Documentation

Index

Constants

View Source
const (
	AggregateSum = "SUM"
	AggregateMin = "MIN"
	AggregateMax = "MAX"
)
View Source
const CacheKey = "cache_key"

Variables

View Source
var DefaultLRUCache = NewLRUCache(defaultMaxEntryNum)
View Source
var KeyPrefix = ""

Functions

This section is empty.

Types

type CacheData

type CacheData struct {
	StoreTime time.Time
	// contains filtered or unexported fields
}

缓存的数据格式

func NewCacheData

func NewCacheData() *CacheData

func (*CacheData) Compress

func (this *CacheData) Compress(value []byte) (err error)

func (*CacheData) UnCompress

func (this *CacheData) UnCompress() ([]byte, error)

type Compressor

type Compressor interface {
	Compress([]byte) error
	UnCompress() ([]byte, error)
}

type LRUCache

type LRUCache struct {
	Cache *lru.Cache // 可以通过它直接调用非锁定方法
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(maxEntries int) *LRUCache

func (*LRUCache) Add

func (this *LRUCache) Add(key, value interface{})

func (*LRUCache) CompressAndAdd

func (this *LRUCache) CompressAndAdd(key interface{}, value []byte, compressor Compressor)

CompressAndAdd 对数据进行 gzip 压缩之后再加入缓存中

func (*LRUCache) Get

func (this *LRUCache) Get(key interface{}) (value interface{}, ok bool)

func (*LRUCache) GetAndUnCompress

func (this *LRUCache) GetAndUnCompress(key interface{}) (value []byte, compressor Compressor, ok bool)

GetAndUnCompress 获取数据并解压缩(Gunzip)

func (*LRUCache) Len

func (this *LRUCache) Len() int

func (*LRUCache) Remove

func (this *LRUCache) Remove(key interface{})

func (*LRUCache) RemoveOldest

func (this *LRUCache) RemoveOldest()

type RedisClient

type RedisClient struct {
	redis.Conn

	NoPrefix bool
	// contains filtered or unexported fields
}

func NewRedisClient

func NewRedisClient() *RedisClient

NewRedisClient 通过 redis 配置获取 redis 连接实例

func NewRedisClientWithSection

func NewRedisClientWithSection(section string) *RedisClient

NewRedisClientWithSection 通过传递进来的 section 配置获取 redis 连接实例

func NewRedisFromPool

func NewRedisFromPool() *RedisClient

NewRedisFromPool 使用连接池(只支持主 redis 实例)

func (*RedisClient) Close

func (this *RedisClient) Close()

func (*RedisClient) DECR

func (this *RedisClient) DECR(key string) (int64, error)

func (*RedisClient) DEL

func (this *RedisClient) DEL(key string) error

func (*RedisClient) EXPIRE

func (this *RedisClient) EXPIRE(key string, expireSeconds int) error

func (*RedisClient) GET

func (this *RedisClient) GET(key string) string

func (*RedisClient) HDEL

func (this *RedisClient) HDEL(key, field string) error

func (*RedisClient) HEXISTS

func (this *RedisClient) HEXISTS(key, field string) (bool, error)

func (*RedisClient) HGET

func (this *RedisClient) HGET(key, field string) (string, error)

func (*RedisClient) HGETALL

func (this *RedisClient) HGETALL(key string) (map[string]string, error)

func (*RedisClient) HLEN

func (this *RedisClient) HLEN(key string) (int, error)

func (*RedisClient) HSCAN

func (this *RedisClient) HSCAN(key string, cursor interface{}, optionArgs ...interface{}) (uint64, map[string]string, error)

func (*RedisClient) HSET

func (this *RedisClient) HSET(key, field, val string) error

func (*RedisClient) INCR

func (this *RedisClient) INCR(key string) (int64, error)

func (*RedisClient) SADD

func (this *RedisClient) SADD(key string, members ...string) (int, error)

func (*RedisClient) SCARD

func (this *RedisClient) SCARD(key string) (int, error)

func (*RedisClient) SET

func (this *RedisClient) SET(key string, val interface{}, expireSeconds int) error

func (*RedisClient) SUNIONSTORE

func (this *RedisClient) SUNIONSTORE(destination string, keys ...string) (int, error)

func (*RedisClient) ZADD

func (this *RedisClient) ZADD(key string, score, member interface{}, optionArgs ...interface{}) error

func (*RedisClient) ZCARD

func (this *RedisClient) ZCARD(key string) int

func (*RedisClient) ZINCRBY

func (this *RedisClient) ZINCRBY(key string, increment, member interface{}) error

func (*RedisClient) ZRANGE

func (this *RedisClient) ZRANGE(key string, start, stop int, withscores bool) ([]interface{}, error)

func (*RedisClient) ZRANK

func (this *RedisClient) ZRANK(key string, member interface{}) int

func (*RedisClient) ZREVRANGE

func (this *RedisClient) ZREVRANGE(key string, start, stop int, withscores bool) ([]interface{}, error)

func (*RedisClient) ZREVRANK

func (this *RedisClient) ZREVRANK(key string, member interface{}) int

ZREVRANK 返回排名,-1 表示 member 不存在或错误

func (*RedisClient) ZSCAN

func (this *RedisClient) ZSCAN(key string, cursor interface{}, optionArgs ...interface{}) (uint64, []interface{}, error)

func (*RedisClient) ZUNIONSTORE

func (this *RedisClient) ZUNIONSTORE(dest string, keyNum int, keys []string, zsetArgs *ZSetArgs) error

type ZSetArgs

type ZSetArgs struct {
	Weights   []int
	Aggregate string
}

zset 数据结构附加的参数

Jump to

Keyboard shortcuts

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