db

package
v0.0.0-...-9d183bc Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close closes the default singleton database connection.

func CloseAll

func CloseAll() error

CloseAll closes all managed database connections.

func CloseDB

func CloseDB(bunDB *bun.DB) error

CloseDB closes a specific database connection and removes it from the cache.

func Connect

func Connect(config Config) (*bun.DB, error)

Connect establishes a connection to a specific database and caches it.

func CreateKey

func CreateKey(s1 string, s2 string) string

func GetDB

func GetDB() *bun.DB

GetDB returns the singleton default Bun database instance.

func GetOrConnect

func GetOrConnect(config Config) (*bun.DB, error)

GetOrConnect returns an existing connection or creates a new one.

func GetRedis

func GetRedis() *redis.Client

GetRedis returns the singleton Redis client instance

func RedisGet

func RedisGet(ctx context.Context, key string) (string, error)

Get wraps redis GET operation

func RedisHDel

func RedisHDel(ctx context.Context, key string, fields ...string) (int64, error)

RedisHDel removes one or more hash fields from Redis

func RedisHExists

func RedisHExists(ctx context.Context, key string, field string) (bool, error)

RedisHExists checks if a hash field exists in Redis

func RedisHGet

func RedisHGet(ctx context.Context, key string, field string) (string, error)

RedisHGet retrieves a hash field value from Redis

func RedisHGetAll

func RedisHGetAll(ctx context.Context, key string) (map[string]string, error)

RedisHGetAll retrieves all fields and values of a hash from Redis

func RedisHSet

func RedisHSet(ctx context.Context, key string, fields interface{}, expiration time.Duration) error

RedisHSet creates or updates multiple hash fields in Redis

func RedisRemoveKey

func RedisRemoveKey(ctx context.Context, key string) (int64, error)

func RedisSet

func RedisSet(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set wraps redis SET operation

Types

type Config

type Config struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

Config holds database configuration.

Directories

Path Synopsis
models
k8s

Jump to

Keyboard shortcuts

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