storage

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSlugAlreadyExists = errors.New("slug already exists")

Functions

This section is empty.

Types

type Link struct {
	Slug    string    `json:"slug"`
	Url     string    `json:"url"`
	Uses    int       `json:"uses"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

type Mysql

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

func NewMysql

func NewMysql(connect string, slugLength int) (*Mysql, error)

func (*Mysql) All

func (s *Mysql) All() []*Link

func (*Mysql) Close

func (s *Mysql) Close() error

func (*Mysql) Create

func (s *Mysql) Create(url string) (*Link, error)

func (*Mysql) Delete

func (s *Mysql) Delete(slug string) error

func (*Mysql) TryUse

func (s *Mysql) TryUse(slug string) *Link

func (*Mysql) Update

func (s *Mysql) Update(slug, url string) error

type Storage

type Storage interface {
	Create(url string) (*Link, error)
	All() []*Link
	Update(slug, url string) error
	Delete(slug string) error
	TryUse(slug string) *Link
}

Jump to

Keyboard shortcuts

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