Documentation ¶
Overview ¶
Package redisx - an extension of redis library.
Index ¶
- Constants
- Variables
- func Del(keys ...string)
- func Get[T any](key string) (*T, error)
- func GetEx[T any](key string, ttl time.Duration) (*T, error)
- func GetExWithProvider[T any](key string, ttl time.Duration, provider Provider[T]) (*T, error)
- func GetWithProvider[T any](key string, ttl time.Duration, provider Provider[T]) (*T, error)
- func NewClient(cfg *Config) (redis.UniversalClient, error)
- func Set(key string, value any, ttl time.Duration) error
- type Config
- type Provider
Constants ¶
const ( KeyAddrs = "server.redis.address" KeyMaster = "server.redis.master.name" KeyClient = "server.redis.client.name" KeyUsername = "server.redis.username" KeyPassword = "server.redis.password" KeyDatabase = "server.redis.database" KeyReadTimeout = "server.redis.read.timeout" KeyWriteTimeout = "server.redis.read.timeout" )
Variables ¶
var (
Client redis.UniversalClient
)
Functions ¶
func Get ¶
Get - retrieves the value of given key stored in redis server. This function call jsonx function to decode string values to given type.
func GetEx ¶
GetEx - retrieves the value stored in redis server and prolong the TTL of the given key.
func GetExWithProvider ¶ added in v0.0.17
GetExWithProvider - retrieves value of given key as given type. If the given key is not existed, this function will call given provider function to generate the new data, and set the new generated data to cache storage with given TTL.
This function will exit when the data provider returns an error.
func GetWithProvider ¶ added in v0.0.17
GetWithProvider - retrieves value of given key as given type. If the given key is not existed, this function will call given provider function to generate the new data, and set the new generated data to cache storage with given TTL.
This function will exit when the data provider returns an error.