126 lines
4.0 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;
namespace Learun.Cache.Base
{
/// <summary>
/// 版 本 PIT-ADMS V7.0.3 敏捷开发框架
/// Copyright (c) 2013-2018 Hexagon PPM
/// 创建人:研发部
/// 日 期2017.03.06
/// 描 述:定义缓存接口
/// </summary>
public interface ICache
{
/// <summary>
/// 查询redis里key的数据如果没有就执行 dbQuery 里的sql查询并写入一个新的key
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="cacheKey"></param>
/// <param name="projId"></param>
/// <param name="dbQuery"></param>
/// <param name="expireTime"></param>
/// <param name="dbId"></param>
/// <returns></returns>
T GetRedisOrDBData<T>(string cacheKey, string projId, Func<T> dbQuery, TimeSpan? expireTime = null, int dbId = 0);
#region Key-Value
/// <summary>
/// 读取缓存
/// </summary>
/// <param name="cacheKey">键</param>
/// <returns></returns>
T Read<T>(string cacheKey, int dbId = 0) where T : class;
/// <summary>
/// 写入缓存
/// </summary>
/// <param name="value">对象数据</param>
/// <param name="cacheKey">键</param>
void Write<T>(string cacheKey, T value, int dbId = 0) where T : class;
/// <summary>
/// 写入缓存
/// </summary>
/// <param name="value">对象数据</param>
/// <param name="cacheKey">键</param>
/// <param name="expireTime">到期时间</param>
void Write<T>(string cacheKey, T value, TimeSpan timeSpan, int dbId = 0) where T : class;
/// <summary>
/// 移除指定数据缓存
/// </summary>
/// <param name="cacheKey">键</param>
void Remove(string cacheKey, int dbId = 0);
/// <summary>
/// sws用的
/// </summary>
/// <param name="cacheKey"></param>
/// <param name="projId"></param>
/// <param name="dbId"></param>
void Remove(string cacheKey, string projId, int dbId = 0);
/// <summary>
/// 移除全部缓存
/// </summary>
void RemoveAll(int dbId = 0);
#endregion
#region List
#region
/// <summary>
/// 移除指定ListId的内部List的值
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
void ListRemove<T>(string cacheKey, T value, int dbId = 0) where T : class;
/// <summary>
/// 获取指定key的List
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
List<T> ListRange<T>(string cacheKey, int dbId = 0) where T : class;
/// <summary>
/// 入队
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
void ListRightPush<T>(string cacheKey, T value, int dbId = 0) where T : class;
/// <summary>
/// 出队
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
T ListRightPop<T>(string cacheKey, int dbId = 0) where T : class;
/// <summary>
/// 入栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
void ListLeftPush<T>(string cacheKey, T value, int dbId = 0) where T : class;
/// <summary>
/// 出栈
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
T ListLeftPop<T>(string cacheKey, int dbId = 0) where T : class;
/// <summary>
/// 获取集合中的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
long ListLength(string cacheKey, int dbId = 0);
#endregion
#endregion List
}
}