model

package
v0.0.0-...-23edbc9 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheURLRepo

type CacheURLRepo struct {
	URLDB
	RedisClient *redis.Client
}

func (CacheURLRepo) Get

func (s CacheURLRepo) Get(shortURL string) (URLMapping, error)

func (CacheURLRepo) Save

func (s CacheURLRepo) Save(shortURL string, urlMapping URLMapping, expTime time.Duration) error

func (CacheURLRepo) Update

func (s CacheURLRepo) Update(shortURL string, urlMapping URLMapping) error

type SQLURLRepo

type SQLURLRepo struct {
	DB *sql.DB
}

func (SQLURLRepo) Get

func (s SQLURLRepo) Get(shortURL string) (URLMapping, error)

func (SQLURLRepo) Save

func (s SQLURLRepo) Save(shortURL string, urlMapping URLMapping, expTime time.Duration) error

func (SQLURLRepo) Update

func (s SQLURLRepo) Update(shortURL string, urlMapping URLMapping) error

type URLDB

type URLDB interface {
	Save(shortURL string, urlMapping URLMapping, expTime time.Duration) error
	Get(shortURL string) (URLMapping, error)
	Update(shortURL string, urlMapping URLMapping) error
}

type URLMapping

type URLMapping struct {
	OriginalURL string    `json:"original_url"`
	Count       int       `json:"count"`
	ExpTime     time.Time `json:"exp_time"`
}

func (URLMapping) MarshalBinary

func (s URLMapping) MarshalBinary() ([]byte, error)

func (*URLMapping) UnmarshalBinary

func (s *URLMapping) UnmarshalBinary(data []byte) error

type URLRepo

type URLRepo interface {
	Save(shortURL string, urlMapping URLMapping, expTime time.Duration) error
	Get(shortURL string) (URLMapping, error)
	Update(shortURL string, urlMapping URLMapping) error
}

Jump to

Keyboard shortcuts

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