cache

package
v0.0.0-...-276be26 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 13 Imported by: 7

Documentation

Index

Constants

View Source
const (
	AlgorithmHS256    = "HS256"
	DefaultSigningKey = "fxxking-secrets-here"
)

Variables

This section is empty.

Functions

func AddZone

func AddZone()

func DelUserHash

func DelUserHash(uid uint64, did string, token string)

func DelZone

func DelZone()

func Do

func Do(args ...interface{}) (cmd *redis.Cmd)

func Exists

func Exists(key string) (yes bool)

func FindLivingUids

func FindLivingUids(uid uint64) (ret map[string][]string)

func Get

func Get(key string) (val string)

func GetClient

func GetClient() redis.Cmdable

func GetClientFor

func GetClientFor(readOnly bool) redis.Cmdable

func GetClientForWrite

func GetClientForWrite() redis.Cmdable

func GetRedisRd

func GetRedisRd() redis.Cmdable

func GetRedisRw

func GetRedisRw() redis.Cmdable

func GetUserToken

func GetUserToken(uid uint64, did string) (token string, err error)

返回值 err == redis.Nil 表示 uid+did 不存在, 此时并非关键性错误

func GetUserZone

func GetUserZone(uid uint64, did string) (zoneId string, err error)

返回值 err == redis.Nil 表示 uid+did 不存在, 此时并非关键性错误

func HashDel

func HashDel(key, field string)

func HashExists

func HashExists(key, field string) bool

func HashGet

func HashGet(key, field string) (st *redis.StringCmd)

func HashPut

func HashPut(key, field string, val interface{})

func IsUserInZone

func IsUserInZone(uid uint64, did string, zoneId string) (yes bool)

func IsUserTokenValid

func IsUserTokenValid(token string) (valid bool)

func JwtDecodeToken

func JwtDecodeToken(tokenString string) (token *jwt.Token, valid bool, err error)

func JwtExtract

func JwtExtract(c echo.Context) (token *jwt.Token, valid bool, err error)

func JwtExtractToken

func JwtExtractToken(tokenString string) (token *jwt.Token, err error)

func JwtInit

func JwtInit()

func JwtSign

func JwtSign(userId, deviceId string) (string, error)

func JwtVerifyToken

func JwtVerifyToken(tokenString string) (valid bool, err error)

func ListGet

func ListGet(key string) (list []interface{})

func ListPut

func ListPut(key string, val interface{})

func PipelineExec

func PipelineExec(fn func(pipeline redis.Pipeliner) (err error)) (err error)

func Publish

func Publish(channel string, message interface{}) *redis.IntCmd

func Put

func Put(key string, val interface{})

func PutUserHash

func PutUserHash(uid uint64, did string, token string, expire time.Duration)

* <root>

"tokens":token = uid(hex) -> did
"token-to-zone":token = zoneId
"users":uid:did = token
"zones":zoneId = token

<root>:

  im-core:
	zones:
	  z: []zid						// instance id
	  t:							// tokens...
		<zid>:
		  tks: []token				// token string
		  usr:						// users and devices...
			<uid>:<did>: = token	// token string
	  u:
		<uid>:<did>: = token

func Start

func Start()

func StartWithConfig

func StartWithConfig(config *Config)

func Stop

func Stop()

func Subscribe

func Subscribe(channels ...string) (pubsub *redis.PubSub)

func TokenToUserId

func TokenToUserId(token string) (uid uint64, did string)

func TxPipelineExec

func TxPipelineExec(fn func(pipeline redis.Pipeliner) (err error)) (err error)

func Watch

func Watch(fn func(*redis.Tx) error, keys ...string) error

Types

type Config

type Config struct {
	Peers         []string      `yaml:"peers"`
	Username      string        `yaml:"user"'`
	Password      string        `yaml:"pass"`
	Db            int           `yaml:"db"`
	ReadonlyRoute bool          `yaml:readonly-route`
	DialTimeout   time.Duration `yaml:"dial-timeout"`
	ReadTimeout   time.Duration `yaml:"read-timeout"`
	WriteTimeout  time.Duration `yaml:"write-timeout"`
	EnableCluster bool          `yaml:"enable-cluster"`
}

type Hub

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

Jump to

Keyboard shortcuts

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