store

package
v0.0.0-...-31d4dac Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package store implements data persistence

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	*sqlx.DB
}

func New

func New(config *entity.Config) (*Database, error)

New initializes a new database connection

func (*Database) GetLongURL

func (db *Database) GetLongURL(slug string) (string, error)

GetLongURL retrieves the destination/long url corresponding to short url slug

func (*Database) GetURLMetrics

func (db *Database) GetURLMetrics(slug string, date string) (entity.Metric, error)

GetURLMetrics retrieves the number of times a short url has been accessed

func (*Database) SaveURLMapping

func (db *Database) SaveURLMapping(slug string, longURL string) error

SaveURLMapping insert new short url slug to long url entry

func (*Database) SaveURLVist

func (db *Database) SaveURLVist(slug string, date string) error

SaveURLVist inserts URL visit event entry in the store

type StoreInterface

type StoreInterface interface {
	GetLongURL(slug string) (string, error)
	SaveURLMapping(slug string, longURL string) error
	GetURLMetrics(slug string, date string) (entity.Metric, error)
	SaveURLVist(slug string, date string) error
}

Jump to

Keyboard shortcuts

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