storage

package
v2.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is a standard error for when a key is not found in the storage engine

Functions

func HashKey

func HashKey(in string) string

func HashStr

func HashStr(in string) string

func NewRedisClusterPool

func NewRedisClusterPool(isCache bool) *rediscluster.RedisCluster

Types

type Handler

type Handler interface {
	GetKey(string) (string, error) // Returned string is expected to be a JSON object (user.SessionState)
	GetRawKey(string) (string, error)
	SetKey(string, string, int64) error // Second input string is expected to be a JSON object (user.SessionState)
	SetRawKey(string, string, int64) error
	GetExp(string) (int64, error) // Returns expiry of a key
	GetKeys(string) []string
	DeleteKey(string) bool
	DeleteRawKey(string) bool
	Connect() bool
	GetKeysAndValues() map[string]string
	GetKeysAndValuesWithFilter(string) map[string]string
	DeleteKeys([]string) bool
	Decrement(string)
	IncrememntWithExpire(string, int64) int64
	SetRollingWindow(key string, per int64, val string, pipeline bool) (int, []interface{})
	GetSet(string) (map[string]string, error)
	AddToSet(string, string)
	AppendToSet(string, string)
	GetAndDeleteSet(string) []interface{}
	RemoveFromSet(string, string)
	DeleteScanMatch(string) bool
}

Handler is a standard interface to a storage backend, used by AuthorisationManager to read and write key values to the backend

type RedisCluster

type RedisCluster struct {
	KeyPrefix string
	HashKeys  bool
	IsCache   bool
}

RedisCluster is a storage manager that uses the redis database.

func (RedisCluster) AddToSet

func (r RedisCluster) AddToSet(keyName, value string)

func (RedisCluster) AppendToSet

func (r RedisCluster) AppendToSet(keyName, value string)

func (RedisCluster) Connect

func (r RedisCluster) Connect() bool

Connect will establish a connection to the r.singleton()

func (RedisCluster) Decrement

func (r RedisCluster) Decrement(keyName string)

Decrement will decrement a key in redis

func (RedisCluster) DeleteKey

func (r RedisCluster) DeleteKey(keyName string) bool

DeleteKey will remove a key from the database

func (RedisCluster) DeleteKeys

func (r RedisCluster) DeleteKeys(keys []string) bool

DeleteKeys will remove a group of keys in bulk

func (RedisCluster) DeleteRawKey

func (r RedisCluster) DeleteRawKey(keyName string) bool

DeleteKey will remove a key from the database without prefixing, assumes user knows what they are doing

func (RedisCluster) DeleteScanMatch

func (r RedisCluster) DeleteScanMatch(pattern string) bool

DeleteKeys will remove a group of keys in bulk

func (RedisCluster) GetAndDeleteSet

func (r RedisCluster) GetAndDeleteSet(keyName string) []interface{}

func (RedisCluster) GetExp

func (r RedisCluster) GetExp(keyName string) (int64, error)

func (RedisCluster) GetKey

func (r RedisCluster) GetKey(keyName string) (string, error)

GetKey will retrieve a key from the database

func (RedisCluster) GetKeyTTL

func (r RedisCluster) GetKeyTTL(keyName string) (ttl int64, err error)

func (RedisCluster) GetKeys

func (r RedisCluster) GetKeys(filter string) []string

GetKeys will return all keys according to the filter (filter is a prefix - e.g. tyk.keys.*)

func (RedisCluster) GetKeysAndValues

func (r RedisCluster) GetKeysAndValues() map[string]string

GetKeysAndValues will return all keys and their values - not to be used lightly

func (RedisCluster) GetKeysAndValuesWithFilter

func (r RedisCluster) GetKeysAndValuesWithFilter(filter string) map[string]string

GetKeysAndValuesWithFilter will return all keys and their values with a filter

func (RedisCluster) GetRawKey

func (r RedisCluster) GetRawKey(keyName string) (string, error)

func (RedisCluster) GetSet

func (r RedisCluster) GetSet(keyName string) (map[string]string, error)

func (RedisCluster) IncrememntWithExpire

func (r RedisCluster) IncrememntWithExpire(keyName string, expire int64) int64

IncrementWithExpire will increment a key in redis

func (RedisCluster) IsMemberOfSet

func (r RedisCluster) IsMemberOfSet(keyName, value string) bool

func (RedisCluster) Publish

func (r RedisCluster) Publish(channel, message string) error

func (RedisCluster) RemoveFromSet

func (r RedisCluster) RemoveFromSet(keyName, value string)

func (RedisCluster) SetKey

func (r RedisCluster) SetKey(keyName, session string, timeout int64) error

SetKey will create (or update) a key value in the store

func (RedisCluster) SetRawKey

func (r RedisCluster) SetRawKey(keyName, session string, timeout int64) error

func (RedisCluster) SetRollingWindow

func (r RedisCluster) SetRollingWindow(keyName string, per int64, value_override string, pipeline bool) (int, []interface{})

SetRollingWindow will append to a sorted set in redis and extract a timed window of values

func (RedisCluster) StartPubSubHandler

func (r RedisCluster) StartPubSubHandler(channel string, callback func(interface{})) error

StartPubSubHandler will listen for a signal and run the callback for every subscription and message event.

Jump to

Keyboard shortcuts

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