using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CarLocalMeter
{
///
/// 缓存接口
///
public interface ICache
{
#region 设置缓存
///
/// 设置缓存
/// 注:默认过期类型为绝对过期
///
/// 主键
/// 值
/// 过期时间间隔
/// 过期类型
void SetCache(string key, object value, int timeout = 0, ExpireType expireType = default);
///
/// 设置键失效时间
///
/// 键值
/// 从现在起时间间隔
void SetKeyExpire(string key, int expire);
#endregion
#region 获取缓存
///
/// 获取缓存
///
/// 主键
/// 数据类型
T GetCache(string key);
#endregion
#region 删除缓存
///
/// 清除缓存
///
/// 主键
void RemoveCache(string key);
#endregion
}
#region 类型定义
///
/// 值信息
///
public struct ValueInfoEntry
{
public string Value { get; set; }
public string TypeName { get; set; }
public int ExpireTime { get; set; }
public ExpireType? ExpireType { get; set; }
}
///
/// 过期类型
///
public enum ExpireType
{
///
/// 绝对过期
/// 注:即自创建一段时间后就过期
///
Absolute,
///
/// 相对过期
/// 注:即该键未被访问后一段时间后过期,若此键一直被访问则过期时间自动延长
///
Relative,
}
#endregion
}