store

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotExist = errors.New("the URL does not exist")

Functions

This section is empty.

Types

type Conf

type Conf struct {
	DBPath              string
	MaxOpenConns        int
	MaxIdleConns        int
	ConnMaxLifetimeMins int
	ShortURLLength      int
	BufferSize          int // Number of URLs to buffer before flush
	FlushInterval       time.Duration
}

type Store

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

func New

func New(cfg Conf, logger *slog.Logger) (*Store, error)

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateShortURL

func (s *Store) CreateShortURL(ctx context.Context, url string, title string, slug string, expiry time.Duration, deviceURLs map[string]string) (string, error)

func (*Store) DeleteURL

func (s *Store) DeleteURL(ctx context.Context, shortCode string) error

func (*Store) GetRedirectData

func (s *Store) GetRedirectData(ctx context.Context, shortCode string) (models.URLData, error)

func (*Store) GetURLs

func (s *Store) GetURLs(ctx context.Context, page, perPage int64) ([]models.URLData, int64, error)

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

func (*Store) StartExpiryWorker

func (s *Store) StartExpiryWorker(ctx context.Context)

StartExpiryWorker starts a background goroutine that periodically checks and removes expired URLs

Jump to

Keyboard shortcuts

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