Documentation
¶
Index ¶
- func CloseConnection()
- func FormatLockKey(k string) string
- func IsConnectionInstantiated() bool
- func KeyNotFound(err error) bool
- func Lock(ctx context.Context, duration time.Duration, lockKeys ...*LockKeys) error
- func Unlock(ctx context.Context, lockKeys ...*LockKeys) error
- type Cache
- type Connection
- type LockKeys
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatLockKey ¶
Add prefix to the lock key so it becomes unique.
func IsConnectionInstantiated ¶
func IsConnectionInstantiated() bool
Returns true if connection instance is valid.
func KeyNotFound ¶
KeyNotFound will detect whether error signifies key not found by Redis.
Types ¶
type Cache ¶
type Cache interface {
Set(ctx context.Context, key string, value string, expiration time.Duration) error
Get(ctx context.Context, key string) (string, error)
SetStruct(ctx context.Context, key string, value interface{}, expiration time.Duration) error
GetStruct(ctx context.Context, key string, target interface{}) error
Delete(ctx context.Context, keys ...string) error
Ping(ctx context.Context) error
}
Cache interface specifies the methods implemented for Redis caching. String key and interface{} value are the supported types.
type Connection ¶
func OpenConnection ¶ added in v1.6.4
func OpenConnection(options Options) (*Connection, error)
Creates a singleton connection and returns it for every call.
Click to show internal directories.
Click to hide internal directories.