store

package
v0.0.0-...-53af99f Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CacheDuration = 6 * time.Hour

Variables

View Source
var (
	StoreService = &StorageService{}
)

Top level declarations

Functions

This section is empty.

Types

type MongoStorageService

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

Define the struct wrapper around raw Mongo client

func (*MongoStorageService) RetrieveInitialUrl

func (ss *MongoStorageService) RetrieveInitialUrl(shortUrl string) string

func (*MongoStorageService) SaveUrlMapping

func (ss *MongoStorageService) SaveUrlMapping(shortUrl string, originalUrl string)

type RedisStorageService

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

Define the struct wrapper around raw Redis client

func (*RedisStorageService) RetrieveInitialUrl

func (ss *RedisStorageService) RetrieveInitialUrl(shortUrl string) string

func (*RedisStorageService) SaveUrlMapping

func (ss *RedisStorageService) SaveUrlMapping(shortUrl string, originalUrl string)

type StorageService

type StorageService struct {
	Strategy StorageStrategy
}

StorageService struct now holds the storage strategy

func InitializeStore

func InitializeStore(storageType string) *StorageService

type StorageStrategy

type StorageStrategy interface {
	SaveUrlMapping(string, string)
	RetrieveInitialUrl(string) string
}

Database interface

type UrlDoc

type UrlDoc struct {
	ID        primitive.ObjectID `bson:"_id"`
	LongUrl   string             `bson:"longUrl"`
	ShortUrl  string             `bson:"shortUrl"`
	CreatedAt time.Time          `bson:"createdAt"`
}

Jump to

Keyboard shortcuts

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