database

package
v0.0.0-...-effc6df Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresDB

type PostgresDB struct {
	// contains filtered or unexported fields
}

PostgresDB represents a PostgreSQL database connection

func NewPostgresDB

func NewPostgresDB(cfg config.DatabaseConfig) (*PostgresDB, error)

NewPostgresDB creates a new PostgreSQL database connection

func (*PostgresDB) Close

func (db *PostgresDB) Close()

Close closes the database connection

func (*PostgresDB) GetPool

func (db *PostgresDB) GetPool() *pgxpool.Pool

GetPool returns the connection pool

func (*PostgresDB) Ping

func (db *PostgresDB) Ping(ctx context.Context) error

Ping checks if the database connection is alive

func (*PostgresDB) RunMigrations

func (db *PostgresDB) RunMigrations() error

RunMigrations runs database migrations

type RedisClient

type RedisClient struct {
	// contains filtered or unexported fields
}

RedisClient represents a Redis client connection

func NewRedisClient

func NewRedisClient(cfg config.RedisConfig) (*RedisClient, error)

NewRedisClient creates a new Redis client

func (*RedisClient) Close

func (rc *RedisClient) Close() error

Close closes the Redis client

func (*RedisClient) Delete

func (rc *RedisClient) Delete(ctx context.Context, key string) error

Delete deletes a key from Redis

func (*RedisClient) Exists

func (rc *RedisClient) Exists(ctx context.Context, key string) (bool, error)

Exists checks if a key exists in Redis

func (*RedisClient) Get

func (rc *RedisClient) Get(ctx context.Context, key string) (string, error)

Get gets a value from Redis by key

func (*RedisClient) GetClient

func (rc *RedisClient) GetClient() *redis.Client

GetClient returns the Redis client

func (*RedisClient) Increment

func (rc *RedisClient) Increment(ctx context.Context, key string) (int64, error)

Increment increments a counter in Redis

func (*RedisClient) RateLimiter

func (rc *RedisClient) RateLimiter(ctx context.Context, key string, limit int, window time.Duration) (bool, error)

RateLimiter increments a counter and returns whether the limit is exceeded

func (*RedisClient) Set

func (rc *RedisClient) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set sets a key-value pair in Redis with expiration

func (*RedisClient) SetWithTTL

func (rc *RedisClient) SetWithTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) error

SetWithTTL sets a key-value pair with TTL

Jump to

Keyboard shortcuts

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