Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateToken(orgID, keyID, hashAlgorithm string) (string, error)
- func HashKey(in string) string
- func HashStr(in string, withAlg ...string) string
- func IsConnected() bool
- func NewRedisClusterPool(isCache bool) redis.UniversalClient
- func TokenHashAlgo(token string) string
- func TokenOrg(token string) string
- type Handler
- type RedisCluster
- func (r *RedisCluster) AddToSet(keyName, value string)
- func (r *RedisCluster) AddToSortedSet(keyName, value string, score float64)
- func (r *RedisCluster) AppendToSet(keyName, value string)
- func (r *RedisCluster) AppendToSetPipelined(key string, values []string)
- func (r *RedisCluster) Connect() bool
- func (r *RedisCluster) Decrement(keyName string)
- func (r *RedisCluster) DeleteAllKeys() bool
- func (r *RedisCluster) DeleteKey(keyName string) bool
- func (r *RedisCluster) DeleteKeys(keys []string) bool
- func (r *RedisCluster) DeleteRawKey(keyName string) bool
- func (r *RedisCluster) DeleteScanMatch(pattern string) bool
- func (r *RedisCluster) Exists(keyName string) (bool, error)
- func (r *RedisCluster) GetAndDeleteSet(keyName string) []interface{}
- func (r *RedisCluster) GetExp(keyName string) (int64, error)
- func (r *RedisCluster) GetKey(keyName string) (string, error)
- func (r *RedisCluster) GetKeyPrefix() string
- func (r *RedisCluster) GetKeyTTL(keyName string) (ttl int64, err error)
- func (r *RedisCluster) GetKeys(filter string) []string
- func (r *RedisCluster) GetKeysAndValues() map[string]string
- func (r *RedisCluster) GetKeysAndValuesWithFilter(filter string) map[string]string
- func (r *RedisCluster) GetListRange(keyName string, from, to int64) ([]string, error)
- func (r *RedisCluster) GetMultiKey(keys []string) ([]string, error)
- func (r *RedisCluster) GetRawKey(keyName string) (string, error)
- func (r RedisCluster) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
- func (r *RedisCluster) GetSet(keyName string) (map[string]string, error)
- func (r *RedisCluster) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
- func (r *RedisCluster) IncrememntWithExpire(keyName string, expire int64) int64
- func (r *RedisCluster) IsMemberOfSet(keyName, value string) bool
- func (r *RedisCluster) Publish(channel, message string) error
- func (r *RedisCluster) RemoveFromList(keyName, value string) error
- func (r *RedisCluster) RemoveFromSet(keyName, value string)
- func (r *RedisCluster) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
- func (r *RedisCluster) SetExp(keyName string, timeout int64) error
- func (r *RedisCluster) SetKey(keyName, session string, timeout int64) error
- func (r *RedisCluster) SetRawKey(keyName, session string, timeout int64) error
- func (r *RedisCluster) SetRollingWindow(keyName string, per int64, value_override string, pipeline bool) (int, []interface{})
- func (r *RedisCluster) StartPubSubHandler(channel string, callback func(interface{})) error
- type RedisOpts
Constants ¶
const B64JSONPrefix = "ey"
`{"` in base64
Variables ¶
var ( HashSha256 = "sha256" HashMurmur32 = "murmur32" HashMurmur64 = "murmur64" HashMurmur128 = "murmur128" )
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 GenerateToken ¶
If hashing algorithm is empty, use legacy key generation
func IsConnected ¶
func IsConnected() bool
IsConnected waits with retries until Redis connection pools are connected
func NewRedisClusterPool ¶
func NewRedisClusterPool(isCache bool) redis.UniversalClient
func TokenHashAlgo ¶
Types ¶
type Handler ¶
type Handler interface { GetKey(string) (string, error) // Returned string is expected to be a JSON object (user.SessionState) GetMultiKey([]string) ([]string, error) 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 SetExp(string, int64) error // Set key expiration GetExp(string) (int64, error) // Returns expiry of a key GetKeys(string) []string DeleteKey(string) bool DeleteAllKeys() 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{}) GetRollingWindow(key string, per int64, pipeline bool) (int, []interface{}) GetSet(string) (map[string]string, error) AddToSet(string, string) AppendToSetPipelined(string, []string) GetAndDeleteSet(string) []interface{} RemoveFromSet(string, string) DeleteScanMatch(string) bool GetKeyPrefix() string AddToSortedSet(string, string, float64) GetSortedSetRange(string, string, string) ([]string, []float64, error) RemoveSortedSetRange(string, string, string) error GetListRange(string, int64, int64) ([]string, error) RemoveFromList(string, string) error AppendToSet(string, string) Exists(string) (bool, error) }
Handler is a standard interface to a storage backend, used by AuthorisationManager to read and write key values to the backend
type RedisCluster ¶
RedisCluster is a storage manager that uses the redis database.
func (*RedisCluster) AddToSet ¶
func (r *RedisCluster) AddToSet(keyName, value string)
func (*RedisCluster) AddToSortedSet ¶
func (r *RedisCluster) AddToSortedSet(keyName, value string, score float64)
AddToSortedSet adds value with given score to sorted set identified by keyName
func (*RedisCluster) AppendToSet ¶
func (r *RedisCluster) AppendToSet(keyName, value string)
func (*RedisCluster) AppendToSetPipelined ¶
func (r *RedisCluster) AppendToSetPipelined(key string, values []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) DeleteAllKeys ¶
func (r *RedisCluster) DeleteAllKeys() bool
DeleteAllKeys will remove all keys from the database.
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) Exists ¶
func (r *RedisCluster) Exists(keyName string) (bool, error)
Exists check if keyName exists
func (*RedisCluster) GetAndDeleteSet ¶
func (r *RedisCluster) GetAndDeleteSet(keyName string) []interface{}
func (*RedisCluster) GetKey ¶
func (r *RedisCluster) GetKey(keyName string) (string, error)
GetKey will retrieve a key from the database
func (*RedisCluster) GetKeyPrefix ¶
func (r *RedisCluster) GetKeyPrefix() string
GetPrefix returns storage key prefix
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) GetListRange ¶
func (r *RedisCluster) GetListRange(keyName string, from, to int64) ([]string, error)
GetListRange gets range of elements of list identified by keyName
func (*RedisCluster) GetMultiKey ¶
func (r *RedisCluster) GetMultiKey(keys []string) ([]string, error)
GetMultiKey gets multiple keys from the database
func (RedisCluster) GetRollingWindow ¶
func (r RedisCluster) GetRollingWindow(keyName string, per int64, pipeline bool) (int, []interface{})
func (*RedisCluster) GetSet ¶
func (r *RedisCluster) GetSet(keyName string) (map[string]string, error)
func (*RedisCluster) GetSortedSetRange ¶
func (r *RedisCluster) GetSortedSetRange(keyName, scoreFrom, scoreTo string) ([]string, []float64, error)
GetSortedSetRange gets range of elements of sorted set identified by keyName
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) RemoveFromList ¶
func (r *RedisCluster) RemoveFromList(keyName, value string) error
RemoveFromList delete an value from a list idetinfied with the keyName
func (*RedisCluster) RemoveFromSet ¶
func (r *RedisCluster) RemoveFromSet(keyName, value string)
func (*RedisCluster) RemoveSortedSetRange ¶
func (r *RedisCluster) RemoveSortedSetRange(keyName, scoreFrom, scoreTo string) error
RemoveSortedSetRange removes range of elements from sorted set identified by keyName
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.
type RedisOpts ¶
type RedisOpts redis.UniversalOptions
RedisOpts is the overriden type of redis.UniversalOptions. simple() and cluster() functions are not public in redis library. Therefore, they are redefined in here to use in creation of new redis cluster logic. We don't want to use redis.NewUniversalClient() logic.