using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DS.Module.RedisModule
{
    public interface IRedisService
    {
        /// <summary>
        /// 设置长时间存在的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool SetLongValue(string key, string value);
        /// <summary>
        /// 设置值,并设置清除时间
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="outSecond"></param>
        /// <returns></returns>
        bool SetValue(string key, string value, int outSecond);
        /// <summary>
        /// 设置值,存在则覆盖,并沿用之前的清除时间
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool SetValue(string key, string value);
        /// <summary>
        /// 是否存在key
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Exists(string key);
        // <summary>
        /// 更新Key,把自动注销时间设置为原来的key的时间,不存在返回false
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool UpdateValue(string key, string value);
        /// <summary>
        /// 获取值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string? GetValue(string key);
        /// <summary>
        /// 获得json序列化后的
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T? GetValue<T>(string key);
        /// <summary>
        /// 获取值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T? GetEntity<T>(string key);
        /// <summary>
        /// 获取列表 模糊匹配
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        List<T>? GetLike<T>(string key);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="key"></param>
        void DeleteKey(string key);
        /// <summary>
        /// 模糊删除
        /// </summary>
        /// <param name="key"></param>
        void DeleteLike(string key);

        /// <summary>
        /// 释放Redis链接
        /// </summary>
        void Dispose();
    }
}