models

package
v0.0.0-...-10a49dc Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CahceModel

type CahceModel interface {
	CacheURL(ctx context.Context, url URLS) error
	FetchURL(ctx context.Context, shortenURL string) (string, error)
	SetTTL(ctx context.Context, shortenURL string, ttl time.Duration) error
	GetTTL(ctx context.Context, shortenURL string) (time.Duration, error)
}

type DBModel

type DBModel interface {
	StoreURL(ctx context.Context, url URLS) error
	FetchURL(ctx context.Context, ShortenURL string) (string, error)
}

type Database

type Database struct {
	DB *mongo.Database
}

func (*Database) FetchURL

func (d *Database) FetchURL(ctx context.Context, ShortenedURL string) (string, error)

func (*Database) StoreURL

func (d *Database) StoreURL(ctx context.Context, urls URLS) error

type RedisModel

type RedisModel struct {
	Client *redis.Client
	TTL    time.Duration
}

func NewRedisModel

func NewRedisModel(client *redis.Client, ttl time.Duration) *RedisModel

func (*RedisModel) CacheURL

func (rm *RedisModel) CacheURL(ctx context.Context, url URLS) error

func (*RedisModel) FetchURL

func (rm *RedisModel) FetchURL(ctx context.Context, ShortenedURL string) (string, error)

func (*RedisModel) GetTTL

func (rm *RedisModel) GetTTL(ctx context.Context, shortenURL string) (time.Duration, error)

func (*RedisModel) SetTTL

func (rm *RedisModel) SetTTL(ctx context.Context, shortenURL string, ttl time.Duration) error

type URLModel

type URLModel interface {
	ShortenURL(url string) string
}

type URLS

type URLS struct {
	URL          string `bson:"url"`
	ShortenedURL string `bson:"shorten_url"`
}

func (*URLS) ShortenURL

func (u *URLS) ShortenURL(url string) string

Jump to

Keyboard shortcuts

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