storage

package
v0.0.0-...-4af809f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Offset = 1000000
	// RedisKeyUrlGlobalId 全局Id
	RedisKeyUrlGlobalId = "url:global:id"
	RedisKeyShortUrl    = "url:short:%s"
	RedisKeyUrlDetail   = "url:detail:%s"
	RedisKeyUrlCounter  = "url:counter:%s"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisStorage

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

RedisStorage Redis实现短链服务

func NewRedisStorage

func NewRedisStorage() (*RedisStorage, error)

func (*RedisStorage) ShortLinkInfo

func (r *RedisStorage) ShortLinkInfo(sid string) (*entity.UrlDetailInfo, error)

func (*RedisStorage) Shorten

func (r *RedisStorage) Shorten(url string, expSecond int64) (string, error)

func (*RedisStorage) UnShorten

func (r *RedisStorage) UnShorten(sid string) (string, error)

type Storage

type Storage interface {
	Shorten(url string, expSecond int64) (string, error)     // 将长链转成短链,并设置过期时间
	ShortLinkInfo(sid string) (*entity.UrlDetailInfo, error) // 根据短链id获取详情
	UnShorten(sid string) (string, error)                    // 根据短链id转成原始长链
}

Storage 短链服务抽象接口

Jump to

Keyboard shortcuts

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