kos/pkg/cache/instance.go

39 lines
541 B
Go
Raw Permalink Normal View History

2023-04-23 17:57:36 +08:00
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)
}