Documentation
¶
Index ¶
- func Any[T comparable](items []T, callback func(T) bool) bool
- func Deduplication[T comparable](vs ...T) []T
- func DeduplicationFunc[T comparable](vs []T, fn func(T) string) []T
- func MD5(s string) string
- func Reverse[T any](s []T) []T
- func Unique[T comparable](values []T) bool
- func UseCache[K comparable, V any](fn func(K) (V, error)) func(K) (V, bool, error)
- func UseTTLCache[K comparable, V any](timeline time.Duration, fn func(K) (V, error)) func(K) (V, bool, error)
- func UseTiming(limit time.Duration) func()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶ added in v1.0.18
func Any[T comparable](items []T, callback func(T) bool) bool
Any 存在指定的值即返回 true
func Deduplication ¶ added in v1.0.18
func Deduplication[T comparable](vs ...T) []T
Deduplication 去重
func DeduplicationFunc ¶ added in v1.0.18
func DeduplicationFunc[T comparable](vs []T, fn func(T) string) []T
DeduplicationFunc 自定义条件去重
func UseCache ¶
func UseCache[K comparable, V any](fn func(K) (V, error)) func(K) (V, bool, error)
UseCache 使用内存缓存一些临时数据 由于是临时数据,其 value 应该是一次性数据,用完即丢 第二个返回参数用来标识是否命中缓存
func UseTTLCache ¶ added in v1.0.20
func UseTTLCache[K comparable, V any](timeline time.Duration, fn func(K) (V, error)) func(K) (V, bool, error)
UseTTLCache 使用内存缓存一些临时数据 指定时间超时自动清理
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.