storage

package
v0.0.0-...-21410c9 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

type Storage interface {
	Write(short string, long string) error
	Delete(short string) error
	Read(short string) (string, error)
}

Storage interface is the contract that a struct should meet in order to be used as storage for the API

type StorageDB

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

StorageDB implements Storage interface and it is used to save URL in a real key/value db

func NewStorageDB

func NewStorageDB(dbName string) *StorageDB

NewStorageDB create a new instance of the db

func (StorageDB) Close

func (db StorageDB) Close() error

Close cleanUp resources

func (StorageDB) Delete

func (db StorageDB) Delete(short string) error

Delete deletes a short URL from the db

func (StorageDB) Read

func (db StorageDB) Read(short string) (string, error)

Read retrieves a longURL from a shortURL from the db

func (StorageDB) Write

func (db StorageDB) Write(short string, long string) error

Delete save a [shortURL-longURL] in the db

Jump to

Keyboard shortcuts

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