Documentation ¶
Index ¶
- func GetByteLenByPartitionCount(count int) int
- func GetFnv128(data string) string
- func GetMd5(data string) string
- func GetNewShortLinkDb(config *MysqlDbConfig) db_base.ShortLinkDbInterface
- func GetShortLinkPrefix(partitionCount int, tableNum int) string
- func GetTableNumFromRawLinkKey(partitionCount int, key string) int
- func GetTableNumFromShortLinkPath(partitionCount int, shortLinkPath string) int
- func GetUrlShortKey(url string) string
- func HexStrToInt64(hexStr string) uint64
- func Int64ToHexStr(n uint64) string
- func MsTimeStampToTime(timeStamp int64) time.Time
- type MysqlDbConfig
- type ShortLinkDao
- func (d *ShortLinkDao) DeleteShortLink(ctx context.Context, shortLinkPath string) error
- func (d *ShortLinkDao) GenShortLink(ctx context.Context, rawLink string) (*db_base.ShortLink, error)
- func (d *ShortLinkDao) GenShortLinkWithExpire(ctx context.Context, rawLink string, expireAt time.Time) (*db_base.ShortLink, error)
- func (d *ShortLinkDao) GetByRawLink(ctx context.Context, rawLink string) (*db_base.ShortLink, error)
- func (d *ShortLinkDao) GetByShortLinkPath(ctx context.Context, shortLinkPath string) (*db_base.ShortLink, error)
- func (d *ShortLinkDao) Init(config *MysqlDbConfig) error
- func (d *ShortLinkDao) SetShortLinkExpire(ctx context.Context, shortLinkPath string, expireAt time.Time) error
- type ShortLinkTab
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNewShortLinkDb ¶
func GetNewShortLinkDb(config *MysqlDbConfig) db_base.ShortLinkDbInterface
func GetShortLinkPrefix ¶
func GetUrlShortKey ¶
func HexStrToInt64 ¶
func Int64ToHexStr ¶
func MsTimeStampToTime ¶
Types ¶
type MysqlDbConfig ¶
type ShortLinkDao ¶
type ShortLinkDao struct { Config MysqlDbConfig Engine *xorm.Engine }
func (*ShortLinkDao) DeleteShortLink ¶
func (d *ShortLinkDao) DeleteShortLink(ctx context.Context, shortLinkPath string) error
TODO: add delete table, and reuse the deleted short path
func (*ShortLinkDao) GenShortLink ¶
func (*ShortLinkDao) GenShortLinkWithExpire ¶
func (*ShortLinkDao) GetByRawLink ¶
func (*ShortLinkDao) GetByShortLinkPath ¶
func (*ShortLinkDao) Init ¶
func (d *ShortLinkDao) Init(config *MysqlDbConfig) error
func (*ShortLinkDao) SetShortLinkExpire ¶
type ShortLinkTab ¶
type ShortLinkTab struct { Id int64 `xorm:"pk autoincr BIGINT(20)"` ShortLinkType int `xorm:"INT(11)"` ShortLinkPath string `xorm:"not null VARCHAR(64)"` RawLinkKey string `xorm:"not null unique VARCHAR(64)"` // md5 + fnv128 RawLink string `xorm:"not null VARCHAR(2048)"` ExpireTimestamp int64 `xorm:"index BIGINT(20)"` CreateTimestamp int64 `xorm:"BIGINT(20)"` UpdateTimestamp int64 `xorm:"BIGINT(20)"` }
Click to show internal directories.
Click to hide internal directories.