39 lines
541 B
Go
39 lines
541 B
Go
|
package cache
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
std Cache
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
std = NewMemCache()
|
||
|
}
|
||
|
|
||
|
func SetCache(l Cache) {
|
||
|
std = l
|
||
|
}
|
||
|
|
||
|
func GetCache() Cache {
|
||
|
return std
|
||
|
}
|
||
|
|
||
|
func Set(ctx context.Context, key string, value any) {
|
||
|
std.Set(ctx, key, value)
|
||
|
}
|
||
|
|
||
|
func SetEx(ctx context.Context, key string, value any, expire time.Duration) {
|
||
|
std.SetEx(ctx, key, value, expire)
|
||
|
}
|
||
|
|
||
|
func Get(ctx context.Context, key string) (value any, ok bool) {
|
||
|
return std.Get(ctx, key)
|
||
|
}
|
||
|
|
||
|
func Del(ctx context.Context, key string) {
|
||
|
std.Del(ctx, key)
|
||
|
}
|