Documentation ¶
Index ¶
- type Store
- func (db *Store) Close() (err error)
- func (db *Store) DeleteAlias(ctx context.Context, a string) (err error)
- func (db *Store) FetchAlias(ctx context.Context, a string) (*models.Redir, error)
- func (db *Store) FetchAliasAll(ctx context.Context, public bool, kind models.AliasKind, ...) ([]models.RedirIndex, int64, error)
- func (db *Store) RecordVisit(ctx context.Context, v *models.Visit) (string, error)
- func (db *Store) StatReferer(ctx context.Context, a string, k models.AliasKind, start, end time.Time) ([]models.RefStat, error)
- func (db *Store) StatUA(ctx context.Context, a string, k models.AliasKind, start, end time.Time) ([]models.UAStat, error)
- func (db *Store) StatVisit(ctx context.Context, as []string) (rs []models.VisitRecord, err error)
- func (db *Store) StatVisitHist(ctx context.Context, a string, k models.AliasKind, start, end time.Time) ([]models.TimeHist, error)
- func (db *Store) StatVisits(ctx context.Context, kind models.AliasKind) (rs []models.VisitRecord, err error)
- func (db *Store) StoreAlias(ctx context.Context, r *models.Redir) (err error)
- func (db *Store) UpdateAlias(ctx context.Context, r *models.Redir) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) DeleteAlias ¶
DeleteAlias deletes a given short alias if exists.
func (*Store) FetchAlias ¶
FetchAlias reads a given alias and returns the associated link.
func (*Store) FetchAliasAll ¶
func (db *Store) FetchAliasAll( ctx context.Context, public bool, kind models.AliasKind, pageSize, pageNum int64, ) ([]models.RedirIndex, int64, error)
FetchAliasAll reads all aliases by given page size and page number.
func (*Store) RecordVisit ¶
RecordVisit records a visit event. If the visit is a new user, it returns and ID to set a cookie to the user.
func (*Store) StatReferer ¶
func (db *Store) StatReferer( ctx context.Context, a string, k models.AliasKind, start, end time.Time, ) ([]models.RefStat, error)
StatReferer fetches and counts all referers of a given alias
func (*Store) StatVisit ¶
StatVisit counts the PV/UV of given aliases.
The current approach is to use visitor's IP address.
func (*Store) StatVisitHist ¶
func (db *Store) StatVisitHist( ctx context.Context, a string, k models.AliasKind, start, end time.Time, ) ([]models.TimeHist, error)
StatVisitHist is a enhanced version of StatVisit. It offers the ability to query PV/UV for a range of time.
The current approach is to count IP address.
func (*Store) StatVisits ¶
func (db *Store) StatVisits(ctx context.Context, kind models.AliasKind) (rs []models.VisitRecord, err error)
StatVisits counts the PV/UV of aliases of a given kind.
The current approach is to use visitor's IP address.
func (*Store) StoreAlias ¶
StoreAlias stores a given short alias with the given link if not exists