model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: Apache-2.0 Imports: 2 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// StringType is redis string
	StringType = "string"
	// ListType is redis list
	ListType = "list"
	// SetType is redis set
	SetType = "set"
	// HashType is redis hash
	HashType = "hash"
	// ZSetType is redis sorted set
	ZSetType = "zset"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseObject

type BaseObject struct {
	DB         int        `json:"db"`                   // DB is db index of redis object
	Key        string     `json:"key"`                  // Key is key of redis object
	Expiration *time.Time `json:"expiration,omitempty"` // Expiration is expiration time, expiration of persistent object is nil
	Size       int        `json:"size"`                 // Size is rdb value size in Byte
	Type       string     `json:"type"`
}

BaseObject is basement of redis object

func (*BaseObject) GetDBIndex

func (o *BaseObject) GetDBIndex() int

GetDBIndex returns db index of object

func (*BaseObject) GetElemCount

func (o *BaseObject) GetElemCount() int

GetElemCount returns number of elements in list/set/hash/zset

func (*BaseObject) GetExpiration

func (o *BaseObject) GetExpiration() *time.Time

GetExpiration returns expiration time, expiration of persistent object is nil

func (*BaseObject) GetKey

func (o *BaseObject) GetKey() string

GetKey returns key of object

func (*BaseObject) GetSize

func (o *BaseObject) GetSize() int

GetSize returns rdb value size in Byte

type CallbackFunc

type CallbackFunc func(object RedisObject) bool

CallbackFunc process redis object

type HashObject

type HashObject struct {
	*BaseObject
	Hash map[string][]byte
}

HashObject stores a hash object

func (*HashObject) GetElemCount

func (o *HashObject) GetElemCount() int

GetElemCount returns number of elements in list/set/hash/zset

func (*HashObject) GetType

func (o *HashObject) GetType() string

GetType returns redis object type

func (*HashObject) MarshalJSON

func (o *HashObject) MarshalJSON() ([]byte, error)

MarshalJSON marshal []byte as string

type ListObject

type ListObject struct {
	*BaseObject
	Values [][]byte
}

ListObject stores a list object

func (*ListObject) GetElemCount

func (o *ListObject) GetElemCount() int

GetElemCount returns number of elements in list/set/hash/zset

func (*ListObject) GetType

func (o *ListObject) GetType() string

GetType returns redis object type

func (*ListObject) MarshalJSON

func (o *ListObject) MarshalJSON() ([]byte, error)

MarshalJSON marshal []byte as string

type RedisObject

type RedisObject interface {
	// GetType returns redis type of object: string/list/set/hash/zset
	GetType() string
	// GetKey returns key of object
	GetKey() string
	// GetDBIndex returns db index of object
	GetDBIndex() int
	// GetExpiration returns expiration time, expiration of persistent object is nil
	GetExpiration() *time.Time
	// GetSize returns rdb value size in Byte
	GetSize() int
	// GetElemCount returns number of elements in list/set/hash/zset
	GetElemCount() int
}

RedisObject is interface for a redis object

type SetObject

type SetObject struct {
	*BaseObject
	Members [][]byte
}

SetObject stores a set object

func (*SetObject) GetElemCount

func (o *SetObject) GetElemCount() int

GetElemCount returns number of elements in list/set/hash/zset

func (*SetObject) GetType

func (o *SetObject) GetType() string

GetType returns redis object type

func (*SetObject) MarshalJSON

func (o *SetObject) MarshalJSON() ([]byte, error)

MarshalJSON marshal []byte as string

type StringObject

type StringObject struct {
	*BaseObject
	Value []byte
}

StringObject stores a string object

func (*StringObject) GetType

func (o *StringObject) GetType() string

GetType returns redis object type

func (*StringObject) MarshalJSON

func (o *StringObject) MarshalJSON() ([]byte, error)

MarshalJSON marshal []byte as string

type ZSetEntry

type ZSetEntry struct {
	Member string  `json:"member"`
	Score  float64 `json:"score"`
}

ZSetEntry is a key-score in sorted set

type ZSetObject

type ZSetObject struct {
	*BaseObject
	Entries []*ZSetEntry `json:"entries"`
}

ZSetObject stores a sorted set object

func (*ZSetObject) GetElemCount

func (o *ZSetObject) GetElemCount() int

GetElemCount returns number of elements in list/set/hash/zset

func (*ZSetObject) GetType

func (o *ZSetObject) GetType() string

GetType returns redis object type

Jump to

Keyboard shortcuts

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