123456789101112131415161718192021222324252627282930313233343536373839404142 |
- 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 Try(ctx context.Context, key string, cb LoadFunc) (value any, err error) {
- return std.Try(ctx, key, cb)
- }
- 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)
- }
|