chore: 并入 iotlcm-app 历史到 app/(原提交 f40bda9)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:00 +08:00
1107 changed files with 147143 additions and 0 deletions
@@ -0,0 +1,46 @@
// Package mcache
// @Link https://github.com/xiujiecn/xiu-admin
// @Copyright Copyright (c) 2025 LiXiujie
// @Author Lxj <li@example.com>
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
// 内存缓存管理
package mcache
import (
"context"
"sync"
"time"
"github.com/gogf/gf/v2/os/gcache"
)
// cache 缓存驱动
var (
mcache *gcache.Cache
mu sync.Mutex
)
// Instance 缓存实例
func Instance() *gcache.Cache {
if mcache == nil {
mu.Lock()
if mcache == nil {
mcache = gcache.NewWithAdapter(gcache.NewAdapterMemory())
}
mu.Unlock()
}
return mcache
}
func Set(ctx context.Context, key string, value interface{}, timeout time.Duration) error {
return Instance().Set(ctx, key, value, timeout)
}
func Get(ctx context.Context, key string) (interface{}, error) {
return Instance().Get(ctx, key)
}
func Remove(ctx context.Context, key string) error {
_, err := Instance().Remove(ctx, key)
return err
}