49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
// Package cache ...
|
|
//
|
|
// Description : cache ...
|
|
//
|
|
// Author : go_developer@163.com<白茶清欢>
|
|
//
|
|
// Date : 2026-01-05 09:33
|
|
package cache
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
cacheAbstract "git.zhangdeman.cn/zhangdeman/cache/abstract"
|
|
)
|
|
|
|
var (
|
|
DefaultClient cacheAbstract.ICache = DefaultCache{}
|
|
)
|
|
|
|
type DefaultCache struct {
|
|
}
|
|
|
|
func (d DefaultCache) Exist(ctx context.Context, cacheInstanceFlag string, key string) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (d DefaultCache) TTL(ctx context.Context, cacheInstanceFlag string, key string) (int64, error) {
|
|
// 直接返回已过期
|
|
return -1, nil
|
|
}
|
|
|
|
func (d DefaultCache) Set(ctx context.Context, cacheInstanceFlag string, key string, value any, ttl int64) error {
|
|
// 设置成功
|
|
return nil
|
|
}
|
|
|
|
func (d DefaultCache) Get(ctx context.Context, cacheInstanceFlag string, key string) (any, error) {
|
|
return nil, errors.New("not found")
|
|
}
|
|
|
|
func (d DefaultCache) GetWithParse(ctx context.Context, cacheInstanceFlag string, key string, parseFunc cacheAbstract.ResultParseFunc) (any, error) {
|
|
return d.Get(ctx, cacheInstanceFlag, key)
|
|
}
|
|
|
|
func (d DefaultCache) Delete(ctx context.Context, cacheInstanceFlag string, key string) error {
|
|
return nil
|
|
}
|