using DocumentServiceAPI.Services.IService;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using Furion.DependencyInjection;
|
|
namespace DocumentServiceAPI.Services
|
{
|
/// <summary>
|
/// redis缓存服务
|
/// </summary>
|
public class RedisCacheScService: IRedisCacheService, IScoped
|
{
|
/// <summary>
|
/// 设置一个键值
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <param name="key"></param>
|
/// <param name="value"></param>
|
/// <returns></returns>
|
public bool Add<T>(string key, T value, int expireSeconds = -1)
|
{
|
return RedisHelper.Set(key, value, expireSeconds);
|
}
|
|
public T? Get<T>(string key)
|
{
|
return RedisHelper.Get<T>(key);
|
}
|
/// <summary>
|
/// 获取秒级过期时间
|
/// </summary>
|
/// <param name="key"></param>
|
/// <returns></returns>
|
public long GetTtl(string key)
|
{
|
return RedisHelper.Ttl(key);
|
}
|
}
|
}
|