Documentation ¶
Index ¶
- func GetObjectByKey[T any](redisClient *ClientWithHelpers, key string, object T, expiry ...time.Duration) *T
- type ClientWithHelpers
- func (r ClientWithHelpers) DecrementCounter(key string) *int64
- func (r ClientWithHelpers) DeleteByKey(key string) error
- func (r ClientWithHelpers) DeleteByKeyPattern(pattern string)
- func (r ClientWithHelpers) GetValueByKey(key string, expiry ...time.Duration) string
- func (r ClientWithHelpers) IncrementCounter(key string) *int64
- func (r ClientWithHelpers) IsConnected() bool
- func (r ClientWithHelpers) KeepLockKeyAlive(key string, expiration time.Duration)
- func (r ClientWithHelpers) RateLimit(key string, limitFn func(int) redis_rate.Limit, limit int) (bool, error)
- func (r ClientWithHelpers) SetLockKey(key string, expiration time.Duration, lockOptions ...SetLockKeyOptions) (success bool, err error)
- func (r ClientWithHelpers) SetObjectByKey(key string, object interface{})
- func (r ClientWithHelpers) SetObjectByKeyIndefinitely(key string, object interface{})
- func (r ClientWithHelpers) SetObjectByKeyWithExpiry(key string, object interface{}, expiration time.Duration)
- type SetLockKeyOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetObjectByKey ¶ added in v1.173.0
func GetObjectByKey[T any](redisClient *ClientWithHelpers, key string, object T, expiry ...time.Duration) *T
GetObjectByKey fetches an object from Redis by key. If the key does not exist or there is an error, it returns nil. If an expiry is provided, it will both fetch the key and update its expiry.
Types ¶
type ClientWithHelpers ¶
type ClientWithHelpers struct { Client *redis.Client Available bool }
func GetRedisClient ¶ added in v1.173.0
func GetRedisClient(isDebug bool) *ClientWithHelpers
func NewClient ¶
func NewClient(addr string) *ClientWithHelpers
func (ClientWithHelpers) DecrementCounter ¶ added in v1.248.0
func (r ClientWithHelpers) DecrementCounter(key string) *int64
func (ClientWithHelpers) DeleteByKey ¶
func (r ClientWithHelpers) DeleteByKey(key string) error
func (ClientWithHelpers) DeleteByKeyPattern ¶
func (r ClientWithHelpers) DeleteByKeyPattern(pattern string)
func (ClientWithHelpers) GetValueByKey ¶
func (r ClientWithHelpers) GetValueByKey(key string, expiry ...time.Duration) string
GetValueByKey fetches a value from Redis by key. If the key does not exist or there is an error, it returns an empty string. If an expiry is provided, it will both fetch the key and update its expiry.
func (ClientWithHelpers) IncrementCounter ¶ added in v1.248.0
func (r ClientWithHelpers) IncrementCounter(key string) *int64
func (ClientWithHelpers) IsConnected ¶
func (r ClientWithHelpers) IsConnected() bool
func (ClientWithHelpers) KeepLockKeyAlive ¶ added in v1.224.0
func (r ClientWithHelpers) KeepLockKeyAlive(key string, expiration time.Duration)
func (ClientWithHelpers) SetLockKey ¶ added in v1.223.0
func (r ClientWithHelpers) SetLockKey(key string, expiration time.Duration, lockOptions ...SetLockKeyOptions) (success bool, err error)
SetLockKey attempts to set a lock on the specified key.
func (ClientWithHelpers) SetObjectByKey ¶
func (r ClientWithHelpers) SetObjectByKey(key string, object interface{})
func (ClientWithHelpers) SetObjectByKeyIndefinitely ¶
func (r ClientWithHelpers) SetObjectByKeyIndefinitely(key string, object interface{})
func (ClientWithHelpers) SetObjectByKeyWithExpiry ¶
func (r ClientWithHelpers) SetObjectByKeyWithExpiry(key string, object interface{}, expiration time.Duration)
Click to show internal directories.
Click to hide internal directories.