dao

package
v0.0.0-...-c3c09b5 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PGErrMsgNoRowsFound      = "pg: no rows in result set"
	PGErrMsgNoMultiRowsFound = "pg: multiple rows in result set"
)

Variables

View Source
var (
	RedisErrKeyNotExist = errors.New("redis key not exist")
)

Functions

This section is empty.

Types

type CacheDAO

type CacheDAO interface {
	GetOriginalURL(name string) (string, *business.Error)
	SetOriginalURL(name string, originalURL string) *business.Error
	DeleteOriginalURL(name string) *business.Error
	DeleteMultiOriginalURL(names []string) *business.Error
	AddOriginalURLIDInFilters(originalURL string) *business.Error
	ExistOriginalURLIDInFilters(originalURL string) (bool, *business.Error)
	DeleteOriginalURLIDInFilters(originalURL string) (bool, *business.Error)
	DeleteMultiOriginalURLIDInFilters(originalURLIDs []string) (bool, *business.Error)
}

type Key

type Key struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"createdAt"`
}

type KeyDAO

type KeyDAO interface {
	BatchCreate(num int) (int, *business.Error)
}

type PGKeyDAO

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

func NewPGKeyDAO

func NewPGKeyDAO(logger *loglib.Logger, client *pglib.GOPGClient, randomStrGenerator randstr.RandomStrGenerator) *PGKeyDAO

func (*PGKeyDAO) BatchCreate

func (p *PGKeyDAO) BatchCreate(num int) (int, *business.Error)

type PGUrlDAO

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

func NewPGUrlDAO

func NewPGUrlDAO(logger *loglib.Logger, client *pglib.GOPGClient) *PGUrlDAO

func (*PGUrlDAO) Create

func (p *PGUrlDAO) Create(originalURL string) (*URL, *business.Error)

func (*PGUrlDAO) Delete

func (p *PGUrlDAO) Delete(id string) *business.Error

func (*PGUrlDAO) Expire

func (p *PGUrlDAO) Expire(num int) ([]string, *business.Error)

func (*PGUrlDAO) Get

func (p *PGUrlDAO) Get(id string) (*URL, *business.Error)

type RedisCacheDAO

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

func NewRedisCacheDAO

func NewRedisCacheDAO(logger *loglib.Logger, client *redislib.GORedisClient) *RedisCacheDAO

func (*RedisCacheDAO) AddOriginalURLIDInFilters

func (r *RedisCacheDAO) AddOriginalURLIDInFilters(originalURLID string) *business.Error

func (*RedisCacheDAO) DeleteMultiOriginalURL

func (r *RedisCacheDAO) DeleteMultiOriginalURL(names []string) *business.Error

func (*RedisCacheDAO) DeleteMultiOriginalURLIDInFilters

func (r *RedisCacheDAO) DeleteMultiOriginalURLIDInFilters(originalURLIDs []string) (bool, *business.Error)

func (*RedisCacheDAO) DeleteOriginalURL

func (r *RedisCacheDAO) DeleteOriginalURL(name string) *business.Error

func (*RedisCacheDAO) DeleteOriginalURLIDInFilters

func (r *RedisCacheDAO) DeleteOriginalURLIDInFilters(originalURLID string) (bool, *business.Error)

func (*RedisCacheDAO) ExistOriginalURLIDInFilters

func (r *RedisCacheDAO) ExistOriginalURLIDInFilters(originalURLID string) (bool, *business.Error)

func (*RedisCacheDAO) GetOriginalURL

func (r *RedisCacheDAO) GetOriginalURL(name string) (string, *business.Error)

func (*RedisCacheDAO) SetOriginalURL

func (r *RedisCacheDAO) SetOriginalURL(name string, originalURL string) *business.Error

type URL

type URL struct {
	ID        string    `json:"id"`
	Original  string    `json:"original"`
	CreatedAt time.Time `json:"createdAt"`
	ExpiredAt time.Time `json:"expiredAt"`
}

type UrlDAO

type UrlDAO interface {
	Create(originalURL string) (*URL, *business.Error)
	Get(id string) (*URL, *business.Error)
	Delete(id string) *business.Error
	Expire(num int) ([]string, *business.Error)
}

Jump to

Keyboard shortcuts

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