redis

package
v0.0.0-...-7540414 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToSecond

func ToSecond(second int64) time.Duration

Types

type Cache

type Cache interface {
	//获取缓存对象,如果存在返回true
	Get(key string, result Object) bool
	//设置缓存对象
	Set(key string, value Object)

	//设置缓存对象,并设置过期时间
	SetNx(key string, value Object, extime int64)
	//获取列表
	GetAsList(key string, typeTemplate Object) ListObject
	//向列表中添加对象
	Add(key string, value Object)
	//获取map
	GetAsMap(key string, typeTemplate Object) map[string]Object
	//向map中添加对象
	AddToMap(key string, subkey string, value Object)
	//设置过期时间
	SetEx(key string, extime int64)
}

type Field

type Field struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type FieldMeta

type FieldMeta struct {
	Name string    //字段名称
	Type FieldType //类型
}

type FieldType

type FieldType byte
const (
	FT_TEXT   FieldType = 11 //文本类型
	FT_NUMBER FieldType = 9  //数字
	FT_ENUM   FieldType = 8  //枚举
	FT_ID     FieldType = 7  //id唯一标识
	FT_DATE   FieldType = 6  //日期
)

type IndexMeta

type IndexMeta struct {
	Name   string      //索引名称
	Fields []FieldMeta //字段
}

索引的元数据信息

type ListObject

type ListObject []interface{}

type Object

type Object interface{}

type PageSearchResult

type PageSearchResult struct {
	Id    string         `json:"uuid"` //查询的请求id
	Index int64          `json:"page"` //页码
	Data  []TargetObject `json:"result"`
}

type RedisCache

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

func (*RedisCache) Add

func (this *RedisCache) Add(key string, value Object)

向列表中添加对象

func (*RedisCache) AddToMap

func (this *RedisCache) AddToMap(key string, subkey string, value Object)

向map中添加对象

func (*RedisCache) Get

func (this *RedisCache) Get(key string, result Object) bool

获取缓存对象,如果存在返回true

func (*RedisCache) GetAsList

func (this *RedisCache) GetAsList(key string, typeTemplate Object) ListObject

获取列表

func (*RedisCache) GetAsMap

func (this *RedisCache) GetAsMap(key string, typeTemplate Object) map[string]Object

获取map

func (*RedisCache) Init

func (this *RedisCache) Init(addr string, pwd string, db int)

func (*RedisCache) Set

func (this *RedisCache) Set(key string, value Object)

//设置缓存对象

func (*RedisCache) SetEx

func (this *RedisCache) SetEx(key string, extime int64)

设置过期时间 second

func (*RedisCache) SetNx

func (this *RedisCache) SetNx(key string, value Object, extime int64)

设置缓存对象,并设置过期时间

type RedisLock

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

func (*RedisLock) Lock

func (this *RedisLock) Lock()

func (*RedisLock) Unlock

func (this *RedisLock) Unlock()

type RedisLockFactory

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

func (*RedisLockFactory) Create

func (this *RedisLockFactory) Create(r string) *RedisLock

func (*RedisLockFactory) Init

func (this *RedisLockFactory) Init(c redis.Cmdable, e int64)

type RedisSessionStore

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

分布式session存储实现

func (*RedisSessionStore) Create

func (this *RedisSessionStore) Create(id string)

func (*RedisSessionStore) Delete

func (this *RedisSessionStore) Delete(id string)

func (*RedisSessionStore) Exist

func (this *RedisSessionStore) Exist(id string) bool

func (*RedisSessionStore) GetValue

func (this *RedisSessionStore) GetValue(id, key string) interface{}

func (*RedisSessionStore) Init

func (this *RedisSessionStore) Init(addr string, db int, pwd string, expire int64)

func (*RedisSessionStore) InitByCluster

func (this *RedisSessionStore) InitByCluster(addr []string, pwd string, expire int64)

func (*RedisSessionStore) SetValue

func (this *RedisSessionStore) SetValue(id, key string, value interface{})

func (*RedisSessionStore) Touch

func (this *RedisSessionStore) Touch(id string)

type SearchEngine

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

func (*SearchEngine) BeginSafeFlush

func (this *SearchEngine) BeginSafeFlush(name string)

开始安全flush

func (*SearchEngine) CreateIndex

func (this *SearchEngine) CreateIndex(name string) *searchIndex

创建索引

func (*SearchEngine) EndSafeFlush

func (this *SearchEngine) EndSafeFlush(name string)

结束安全flush,自动替换掉查询用的索引

func (*SearchEngine) Fetch

func (this *SearchEngine) Fetch(name, id string) *SourceObject

func (*SearchEngine) FetchByPage

func (this *SearchEngine) FetchByPage(request string, page int64) *PageSearchResult

按页获取数据

func (*SearchEngine) FlushIndex

func (this *SearchEngine) FlushIndex(name string)

清除索引,将整个索引的数据摧毁

func (*SearchEngine) Init

func (this *SearchEngine) Init(option SearchOption)

func (*SearchEngine) LoadSource

func (this *SearchEngine) LoadSource(name string, obj *SourceObject)

加载和刷新数据

func (*SearchEngine) RemoveBySearch

func (this *SearchEngine) RemoveBySearch(name string, input ...Field)

根据查询条件删除数据,只支持单个条件很正向条件的索引字段删除,数据删除支持搜索删除

func (*SearchEngine) RemoveKeyword

func (this *SearchEngine) RemoveKeyword(name, field, word string)

删除索引中的某个词条

func (*SearchEngine) RemoveSource

func (this *SearchEngine) RemoveSource(name string, obj *SourceObject)

删除数据

func (*SearchEngine) Search

func (this *SearchEngine) Search(name string, input ...Field) *PageSearchResult

type SearchOption

type SearchOption struct {
	PageSize  int64
	PageLife  int64
	RedisAddr string
	RedisDB   int
	RedisPwd  string
}

type SourceObject

type SourceObject struct {
	TargetObject
	Fields map[string][]string `json:"fields"`
}

type TargetObject

type TargetObject struct {
	Id   string          `json:"id"`
	Data json.RawMessage `json:"data"`
}

Jump to

Keyboard shortcuts

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