Documentation
¶
Index ¶
- Constants
- Variables
- func BackoffRetry(ctx context.Context, maxAttempts int, f func() error) error
- func CleanRedisMutex(name string) error
- func Contains(sli []string, str string) bool
- func DeleteObjectsInRedis(ctx context.Context, keys ...string) error
- func EncryptPassword(passwd string) (string, error)
- func EnsureDir(d string) error
- func GenRandomBigString(length int) (string, error)
- func GenerateUniqueID(input string) string
- func GetBooleanQuery(c *gin.Context, key string, dValue bool) bool
- func GetExpiredTimeByPeriod(period string) (*time.Time, error)
- func GetInternalIP() (string, error)
- func GetMaxTime() time.Time
- func GetObjFromRedis(ctx context.Context, k string, obj any) error
- func GetRedisConn() *redis.Client
- func GetUniqueSID() string
- func GetUniqueStr() (string, error)
- func Invoke(fn func() error) error
- func IsDefaultTag(tag string) bool
- func LockRedisKey(ctx context.Context, key string, expiry time.Duration) (func(), error)
- func NewRedisCient(cfg *config.RedisConfig) (ans *redis.Client)
- func NewRedisMutex(name string, expiry time.Duration) *redsync.Mutex
- func NormalizeTag(tag string, digest string) string
- func RadomStringByPhone(phone string) string
- func RandomString(length int) string
- func RoundMoney(v float64) float64
- func SetObjToRedis(ctx context.Context, k string, obj any, expiration time.Duration) error
- func SetupRedis(cfg *config.RedisConfig, t *testing.T)
- func UUIDStr() (string, error)
- func UUIDStrNew() (string, error)
- func WithTimeout(ctx context.Context, timeout time.Duration, f func(ctx2 context.Context))
- type RetryTask
Constants ¶
View Source
const ( NameRegex = `^[a-z0-9]+(?:[._-][a-z0-9]+)*$` KB = 1024 MB = 1024 * KB GB = 1024 * MB TB = 1024 * GB )
View Source
const (
FakeTag = "0000000000"
)
Variables ¶
View Source
var (
MockRedis *miniredis.Miniredis
)
Functions ¶
func BackoffRetry ¶
BackoffRetry retries up to `maxAttempts` times, and the interval will grow exponentially
func CleanRedisMutex ¶
func EncryptPassword ¶
func GenRandomBigString ¶
GenRandomBigString 生成指定长度大写字母组成的随机字符串
func GenerateUniqueID ¶
func GetInternalIP ¶
func GetMaxTime ¶
func GetRedisConn ¶
func GetUniqueSID ¶
func GetUniqueSID() string
func GetUniqueStr ¶
func IsDefaultTag ¶
func LockRedisKey ¶
func NewRedisCient ¶
func NewRedisCient(cfg *config.RedisConfig) (ans *redis.Client)
func NormalizeTag ¶
func RadomStringByPhone ¶
RadomStringByPhone 根据用户电话号码以及当前时间生成随机字符串,8位
func RandomString ¶
func SetObjToRedis ¶
func SetupRedis ¶
func SetupRedis(cfg *config.RedisConfig, t *testing.T)
Types ¶
Click to show internal directories.
Click to hide internal directories.