Documentation ¶
Index ¶
- Constants
- Variables
- func NewStringTuple(values ...*fieldValue) (*stringTuple, error)
- func NewTuple() *stringTuple
- type StorageLocal
- func (st *StorageLocal) CheckShortDataMapping(short string) error
- func (st *StorageLocal) GetMetaDataMapping(short, key string) (string, error)
- func (st *StorageLocal) InitializeStore() error
- func (st *StorageLocal) LoadDataMapping(short string) ([]byte, error)
- func (st *StorageLocal) LoadDataMappingInfo(short string) (map[string]interface{}, error)
- func (st *StorageLocal) RemoveDataMapping(short string) error
- func (st *StorageLocal) RetrieveInitialUrl(shortUrl string) string
- func (st *StorageLocal) SaveDataMapping(data []byte, short string) error
- func (st *StorageLocal) SaveUrlMapping(shortUrl string, originalUrl string, userId string)
- func (st *StorageLocal) SetMetaDataMapping(short, key, value string) error
- func (st *StorageLocal) UpdateDataMapping(data []byte, short string) error
- type StorageRedis
- func (st *StorageRedis) CheckShortDataMapping(short string) error
- func (st *StorageRedis) GetMetaDataMapping(short, key string) (string, error)
- func (st *StorageRedis) InitializeStore() error
- func (st *StorageRedis) LoadDataMapping(short string) ([]byte, error)
- func (st *StorageRedis) LoadDataMappingInfo(short string) (map[string]interface{}, error)
- func (st *StorageRedis) RemoveDataMapping(short string) error
- func (st *StorageRedis) RetrieveInitialUrl(shortUrl string) string
- func (st *StorageRedis) SaveDataMapping(data []byte, short string) error
- func (st *StorageRedis) SaveUrlMapping(shortUrl string, originalUrl string, userId string)
- func (st *StorageRedis) SetMetaDataMapping(short, key, value string) error
- func (st *StorageRedis) UpdateDataMapping(data []byte, short string) error
- type Store
Constants ¶
View Source
const CacheDuration = 6 * time.Hour
Variables ¶
View Source
var ( StoreCtx Store NewStoreLocal func() Store NewStoreRedis func(redisURL string) Store )
Functions ¶
func NewStringTuple ¶
func NewStringTuple(values ...*fieldValue) (*stringTuple, error)
Types ¶
type StorageLocal ¶
type StorageLocal struct {
// contains filtered or unexported fields
}
func (*StorageLocal) CheckShortDataMapping ¶
func (st *StorageLocal) CheckShortDataMapping(short string) error
func (*StorageLocal) GetMetaDataMapping ¶
func (st *StorageLocal) GetMetaDataMapping(short, key string) (string, error)
func (*StorageLocal) InitializeStore ¶
func (st *StorageLocal) InitializeStore() error
func (*StorageLocal) LoadDataMapping ¶
func (st *StorageLocal) LoadDataMapping(short string) ([]byte, error)
func (*StorageLocal) LoadDataMappingInfo ¶
func (st *StorageLocal) LoadDataMappingInfo(short string) (map[string]interface{}, error)
func (*StorageLocal) RemoveDataMapping ¶
func (st *StorageLocal) RemoveDataMapping(short string) error
func (*StorageLocal) RetrieveInitialUrl ¶
func (st *StorageLocal) RetrieveInitialUrl(shortUrl string) string
We should be able to retrieve the initial long URL once the short is provided. This is when users will be calling the shortlink in the url, so what we need to do here is to retrieve the long url and think about redirect.
func (*StorageLocal) SaveDataMapping ¶
func (st *StorageLocal) SaveDataMapping(data []byte, short string) error
func (*StorageLocal) SaveUrlMapping ¶
func (st *StorageLocal) SaveUrlMapping(shortUrl string, originalUrl string, userId string)
We want to be able to save the mapping between the originalUrl
and the generated shortUrl url
func (*StorageLocal) SetMetaDataMapping ¶
func (st *StorageLocal) SetMetaDataMapping(short, key, value string) error
func (*StorageLocal) UpdateDataMapping ¶
func (st *StorageLocal) UpdateDataMapping(data []byte, short string) error
type StorageRedis ¶
type StorageRedis struct {
// contains filtered or unexported fields
}
func (*StorageRedis) CheckShortDataMapping ¶
func (st *StorageRedis) CheckShortDataMapping(short string) error
func (*StorageRedis) GetMetaDataMapping ¶
func (st *StorageRedis) GetMetaDataMapping(short, key string) (string, error)
func (*StorageRedis) InitializeStore ¶
func (st *StorageRedis) InitializeStore() error
func (*StorageRedis) LoadDataMapping ¶
func (st *StorageRedis) LoadDataMapping(short string) ([]byte, error)
func (*StorageRedis) LoadDataMappingInfo ¶
func (st *StorageRedis) LoadDataMappingInfo(short string) (map[string]interface{}, error)
func (*StorageRedis) RemoveDataMapping ¶
func (st *StorageRedis) RemoveDataMapping(short string) error
func (*StorageRedis) RetrieveInitialUrl ¶
func (st *StorageRedis) RetrieveInitialUrl(shortUrl string) string
We should be able to retrieve the initial long URL once the short is provided. This is when users will be calling the shortlink in the url, so what we need to do here is to retrieve the long url and think about redirect.
func (*StorageRedis) SaveDataMapping ¶
func (st *StorageRedis) SaveDataMapping(data []byte, short string) error
func (*StorageRedis) SaveUrlMapping ¶
func (st *StorageRedis) SaveUrlMapping(shortUrl string, originalUrl string, userId string)
We want to be able to save the mapping between the originalUrl
and the generated shortUrl url
func (*StorageRedis) SetMetaDataMapping ¶
func (st *StorageRedis) SetMetaDataMapping(short, key, value string) error
func (*StorageRedis) UpdateDataMapping ¶
func (st *StorageRedis) UpdateDataMapping(data []byte, short string) error
type Store ¶
type Store interface { InitializeStore() error SaveUrlMapping(shortUrl string, originalUrl string, userId string) RetrieveInitialUrl(shortUrl string) string UpdateDataMapping(data []byte, short string) error SaveDataMapping(data []byte, short string) error CheckShortDataMapping(short string) error LoadDataMapping(short string) ([]byte, error) LoadDataMappingInfo(short string) (map[string]interface{}, error) SetMetaDataMapping(short, key, value string) error GetMetaDataMapping(short, key string) (string, error) RemoveDataMapping(short string) error }
Click to show internal directories.
Click to hide internal directories.