redisutils

package
v0.0.0-...-744dbeb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

The redisutils package simplifies and automates recurring operations like connecting to, formatting for, and parsing from Redis.

Index

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

func FormatID[ID uint32 | int64 | int](id ID) string

FormatID() formats a POSITIVE ID into a string. Warning: don't pass negative IDs, or they will be converted incorrectly.

func FormatIDs

func FormatIDs[ID uint32 | int64 | int](IDs []ID) []string

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

func ParseFloat32(strVal string) (float32, error)

ParseFloat32() parses a float32 from the specified string

func ParseFloat64

func ParseFloat64(strVal string) (float64, error)

ParseFloat64() parses a float64 from the specified string

func ParseID

func ParseID(strID string) (uint32, error)

ParseID() parses a nodeID or walkID (uint32) from the specified string

func ParseIDs

func ParseIDs(strIDs []string) ([]uint32, error)

ParseIDs() parses a slice of IDs from the specified slice of string.

func ParseInt64

func ParseInt64(strVal string) (int64, error)

ParseInt64() parses an int from the specified string

func ParseUint16

func ParseUint16(strVal string) (uint16, error)

ParseUint16() parses an uint16 from the specified string

func ParseUniqueIDs

func ParseUniqueIDs(strIDs []string) ([]uint32, error)

ParseUniqueIDs() parses a slice of unique IDs (no repetition), from the specified slice of string.

func ParseUnixTimestamp

func ParseUnixTimestamp(strVal string) (time.Time, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL