qwj
2023-08-16 fed8aa234205247e05305ee7716ae54e894430c7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
        }
    }
}