Files
qhmes/yy-admin-master/YY.Admin.Core/Cache/ISysCacheService.cs

152 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YY.Admin.Core
{
public interface ISysCacheService
{
/// <summary>
/// 申请分布式锁
/// </summary>
IDisposable? BeginCacheLock(string key, int msTimeout = 500, int msExpire = 10000, bool throwOnFailure = true);
/// <summary>
/// 获取缓存键名集合
/// </summary>
List<string> GetKeyList();
/// <summary>
/// 增加缓存
/// </summary>
bool Set(string key, object value);
/// <summary>
/// 增加缓存并设置过期时间
/// </summary>
bool Set(string key, object value, TimeSpan expire);
/// <summary>
/// 异步获取或添加缓存(无参数)
/// </summary>
Task<TR> AdGetAsync<TR>(string cacheName, Func<Task<TR>> del, TimeSpan? expiry = default) where TR : class;
/// <summary>
/// 异步获取或添加缓存1个参数
/// </summary>
Task<TR> AdGetAsync<TR, T1>(string cacheName, Func<T1, Task<TR>> del, T1 t1, TimeSpan? expiry = default) where TR : class;
/// <summary>
/// 异步获取或添加缓存2个参数
/// </summary>
Task<TR> AdGetAsync<TR, T1, T2>(string cacheName, Func<T1, T2, Task<TR>> del, T1 t1, T2 t2, TimeSpan? expiry = default) where TR : class;
/// <summary>
/// 异步获取或添加缓存3个参数
/// </summary>
Task<TR> AdGetAsync<TR, T1, T2, T3>(string cacheName, Func<T1, T2, T3, Task<TR>> del, T1 t1, T2 t2, T3 t3, TimeSpan? expiry = default) where TR : class;
/// <summary>
/// 获取缓存1个参数
/// </summary>
T Get<T>(string cacheName, object t1);
/// <summary>
/// 获取缓存2个参数
/// </summary>
T Get<T>(string cacheName, object t1, object t2);
/// <summary>
/// 获取缓存3个参数
/// </summary>
T Get<T>(string cacheName, object t1, object t2, object t3);
/// <summary>
/// 获取缓存的剩余生存时间
/// </summary>
TimeSpan GetExpire(string key);
/// <summary>
/// 获取缓存
/// </summary>
T Get<T>(string key);
/// <summary>
/// 删除缓存
/// </summary>
int Remove(string key);
/// <summary>
/// 清空所有缓存
/// </summary>
void Clear();
/// <summary>
/// 检查缓存是否存在
/// </summary>
bool ExistKey(string key);
/// <summary>
/// 根据键名前缀删除缓存
/// </summary>
int RemoveByPrefixKey(string prefixKey);
/// <summary>
/// 根据键名前缀获取键名集合
/// </summary>
List<string> GetKeysByPrefixKey(string prefixKey);
/// <summary>
/// 获取缓存值(原始对象)
/// </summary>
object GetValue(string key);
/// <summary>
/// 获取或添加缓存(在数据不存在时执行委托请求数据)
/// </summary>
T GetOrAdd<T>(string key, Func<string, T> callback, int expire = -1);
/// <summary>
/// 获取Hash缓存字典
/// </summary>
IDictionary<string, T> GetHashMap<T>(string key);
/// <summary>
/// 批量添加Hash值
/// </summary>
bool HashSet<T>(string key, Dictionary<string, T> dic);
/// <summary>
/// 添加一条Hash值
/// </summary>
void HashAdd<T>(string key, string hashKey, T value);
/// <summary>
/// 添加或更新一条Hash值
/// </summary>
void HashAddOrUpdate<T>(string key, string hashKey, T value);
/// <summary>
/// 获取多条Hash值
/// </summary>
List<T> HashGet<T>(string key, params string[] fields);
/// <summary>
/// 获取一条Hash值
/// </summary>
T HashGetOne<T>(string key, string field);
/// <summary>
/// 根据KEY获取所有Hash值
/// </summary>
IDictionary<string, T> HashGetAll<T>(string key);
/// <summary>
/// 删除Hash值
/// </summary>
int HashDel<T>(string key, params string[] fields);
}
}