Documentation
¶
Overview ¶
The redisutils package simplifies and automates recurring operations like connecting to, formatting for, and parsing from Redis.
Index ¶
- func CleanupRedis(client *redis.Client)
- func FormatID[ID uint32 | int64 | int](id ID) string
- func FormatIDs[ID uint32 | int64 | int](IDs []ID) []string
- func FormatWalk(walk models.RandomWalk) string
- func ParseFloat32(strVal string) (float32, error)
- func ParseFloat64(strVal string) (float64, error)
- func ParseID(strID string) (uint32, error)
- func ParseIDs(strIDs []string) ([]uint32, error)
- func ParseInt64(strVal string) (int64, error)
- func ParseUint16(strVal string) (uint16, error)
- func ParseUniqueIDs(strIDs []string) ([]uint32, error)
- func ParseUnixTimestamp(strVal string) (time.Time, error)
- func ParseWalk(strWalk string) (models.RandomWalk, error)
- func ParseWalks(strWalks []string) ([]models.RandomWalk, error)
- func SetupProdClient() *redis.Client
- func SetupTestClient() *redis.Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupRedis ¶
func CleanupRedis(client *redis.Client)
CleanupRedis() cleans up the Redis database between tests to ensure isolation.
func FormatID ¶
FormatID() formats a POSITIVE ID into a string. Warning: don't pass negative IDs, or they will be converted incorrectly.
func FormatIDs ¶
FormatIDs() formats a slice of POSITIVE IDs into a slice of string. Warning: don't pass negative IDs, or they will be converted incorrectly.
func FormatWalk ¶
func FormatWalk(walk models.RandomWalk) string
FormatWalk() formats a RandomWalk into a string ready to be stored in Redis.
func ParseFloat32 ¶
ParseFloat32() parses a float32 from the specified string
func ParseFloat64 ¶
ParseFloat64() parses a float64 from the specified string
func ParseInt64 ¶
ParseInt64() parses an int from the specified string
func ParseUint16 ¶
ParseUint16() parses an uint16 from the specified string
func ParseUniqueIDs ¶
ParseUniqueIDs() parses a slice of unique IDs (no repetition), from the specified slice of string.
func ParseUnixTimestamp ¶
ParseUnitTimestamp() parses a unix timestamp string into a time.Time
func ParseWalk ¶
func ParseWalk(strWalk string) (models.RandomWalk, error)
ParseWalk() parses a string to a RandomWalk
func ParseWalks ¶
func ParseWalks(strWalks []string) ([]models.RandomWalk, error)
ParseWalks() parses a slice of strings to a slice of random walks
func SetupProdClient ¶
func SetupProdClient() *redis.Client
SetupProdRedis() initializes a new Redis client for production.
func SetupTestClient ¶
func SetupTestClient() *redis.Client
SetupProdRedis() initializes a new Redis client for production.
Types ¶
This section is empty.