redis_client

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//VersionControlChannelName Version Control Channel Name
	VersionControlChannelName = "version_control"

	//KeySplitChar Key Split Char
	KeySplitChar = ":"
	//CategoryPrefix Category Prefix
	CategoryPrefix = "CV"
	//CategoriesPrefix Categories Prefix
	CategoriesPrefix = "CVS"
)
View Source
const RedisClientTypeID = "0ae35550-7e37-4afe-866e-b129099759b7"

RedisClientTypeID type id

Variables

This section is empty.

Functions

func CategoriesKey

func CategoriesKey(category string) string

CategoriesKey categories key

func CategoryKey

func CategoryKey(category string) string

CategoryKey category key

func GenerateKey

func GenerateKey(keys ...string) string

GenerateKey generate key for redis

func RedisClientConfigTypeLive added in v0.2.1

func RedisClientConfigTypeLive() *dot.ConfigTypeLive

RedisClientConfigTypeLive return config

func RedisClientTypeLives

func RedisClientTypeLives() []*dot.TypeLives

RedisClientTypeLives return type lives

func VersionItemKey

func VersionItemKey(category string, version string, itemKey string) string

VersionItemKey use category,version,item key to generate key of redis

func VersionKey

func VersionKey(category string, version string) string

VersionKey version key

Types

type Operation

type Operation uint8

Operation defines the corresponding operations

const (
	//Set set version
	Set Operation = iota
	//Clean Clean version
	Clean
)

type RedisClient

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

RedisClient redis client dot

func RedisClientTest

func RedisClientTest(jsonConfig string) *RedisClient

RedisClientTest for test

func (*RedisClient) AfterAllDestroy

func (c *RedisClient) AfterAllDestroy(_ dot.Line)

AfterAllDestroy after all destroy

func (*RedisClient) CleanVersion

func (c *RedisClient) CleanVersion(category string, version string) error

CleanVersion del versions in key

func (*RedisClient) ClientV8

func (c *RedisClient) ClientV8() *redis.Client

ClientV8 return redis.Client

func (*RedisClient) Create

func (c *RedisClient) Create(dot.Line) error

Create create dot

func (*RedisClient) Del

func (c *RedisClient) Del(category, version, itemKey string) (int64, error)

Del del key

func (*RedisClient) Get

func (c *RedisClient) Get(category, version, itemKey string) (string, error)

Get get value

func (*RedisClient) GetJsonSerialize

func (c *RedisClient) GetJsonSerialize(category, version, itemKey string, value interface{}) error

Get get value

func (*RedisClient) GetVersion

func (c *RedisClient) GetVersion(category string) (string, error)

GetVersion get current version by category, return version and error.

func (*RedisClient) GetVersions

func (c *RedisClient) GetVersions(category string) ([]string, error)

GetVersions return versions (dictionary order)

func (*RedisClient) Set

func (c *RedisClient) Set(category, version, itemKey, value string, expiration time.Duration) (string, error)

Set set value

func (*RedisClient) SetJsonSerialize

func (c *RedisClient) SetJsonSerialize(category, version, itemKey string, value interface{}, expiration time.Duration) (string, error)

Set set value

func (*RedisClient) SetVersion

func (c *RedisClient) SetVersion(category, version string) error

SetVersion set version for category

type VersionControl

type VersionControl struct {
	// Op indicates the operation of the update.
	Op      Operation `json:"op"`
	Key     string    `json:"key"`
	Version string    `json:"version"`
}

VersionControl defines a version edit.

func (*VersionControl) Marshal

func (c *VersionControl) Marshal() string

Marshal to json string

func (*VersionControl) Unmarshal

func (c *VersionControl) Unmarshal(jsonStr string) (*VersionControl, error)

Unmarshal json string to VersionControl

Jump to

Keyboard shortcuts

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