xxyy
2025-03-05 6d578d016127db97d6f981ff18614ef52a2e0ede
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
namespace WIDESEA_Cache;
 
/// <summary>
/// <inheritdoc cref="ISimpleCacheService"/>
/// Redis缓存
/// </summary>
public partial class RedisCacheService : ISimpleCacheService
{
    private readonly ISimpleRedis _simpleRedis;
 
    public RedisCacheService(ISimpleRedis simpleRedis)
    {
        this._simpleRedis = simpleRedis;
    }
 
    #region 普通操作
 
    /// <inheritdoc/>
    public T Get<T>(string key)
    {
        return _simpleRedis.Get<T>(key);
    }
 
    /// <inheritdoc/>
    public int Remove(params string[] keys)
    {
        return _simpleRedis.GetFullRedis().Remove(keys);
    }
 
    /// <inheritdoc/>
    public bool Set<T>(string key, T value, int expire = -1)
    {
        return _simpleRedis.Set(key, value, expire);
    }
 
    /// <inheritdoc/>
    public bool Set<T>(string key, T value, TimeSpan expire)
    {
        return _simpleRedis.Set(key, value, expire);
    }
 
    /// <inheritdoc/>
    public bool SetExpire(string key, TimeSpan expire)
    {
        return _simpleRedis.GetFullRedis().SetExpire(key, expire);
    }
 
    /// <inheritdoc/>
    public TimeSpan GetExpire(string key)
    {
        return _simpleRedis.GetFullRedis().GetExpire(key);
    }
 
    /// <inheritdoc/>
    public bool ContainsKey(string key)
    {
        return _simpleRedis.ContainsKey(key);
    }
 
    /// <inheritdoc/>
    public void Clear()
    {
        _simpleRedis.Clear();
    }
 
    /// <inheritdoc/>
    public void DelByPattern(string pattern)
    {
        _simpleRedis.DelByPattern(pattern);
    }
 
    #endregion 普通操作
 
    #region 集合操作
 
    /// <inheritdoc/>
    public IDictionary<string, T> GetAll<T>(IEnumerable<string> keys)
    {
        return _simpleRedis.GetFullRedis().GetAll<T>(keys);
    }
 
    /// <inheritdoc/>
    public void SetAll<T>(IDictionary<string, T> values, int expire = -1)
    {
        _simpleRedis.GetFullRedis().SetAll(values, expire);
    }
 
    /// <inheritdoc/>
    public IDictionary<string, T> GetDictionary<T>(string key)
    {
        return _simpleRedis.GetFullRedis().GetDictionary<T>(key);
    }
 
    /// <inheritdoc/>
    public IProducerConsumer<T> GetQueue<T>(string key)
    {
        return _simpleRedis.GetFullRedis().GetQueue<T>(key);
    }
 
    /// <inheritdoc/>
    public IProducerConsumer<T> GetStack<T>(string key)
    {
        return _simpleRedis.GetFullRedis().GetStack<T>(key);
    }
 
    /// <inheritdoc/>
    public ICollection<T> GetSet<T>(string key)
    {
        return _simpleRedis.GetFullRedis().GetSet<T>(key);
    }
 
    #endregion 集合操作
 
    #region 高级操作
 
    /// <inheritdoc/>
    public bool Add<T>(string key, T value, int expire = -1)
    {
        return _simpleRedis.GetFullRedis().Add(key, value, expire);
    }
 
    /// <inheritdoc/>
    public IList<T> GetList<T>(string key)
    {
        return _simpleRedis.GetFullRedis().GetList<T>(key);
    }
 
    /// <inheritdoc/>
    public T Replace<T>(string key, T value)
    {
        return _simpleRedis.GetFullRedis().Replace(key, value);
    }
 
    /// <inheritdoc/>
    public bool TryGetValue<T>(string key, out T value)
    {
        return _simpleRedis.GetFullRedis().TryGetValue(key, out value);
    }
 
    /// <inheritdoc/>
    public long Decrement(string key, long value)
    {
        return _simpleRedis.GetFullRedis().Decrement(key, value);
    }
 
    /// <inheritdoc/>
    public double Decrement(string key, double value)
    {
        return _simpleRedis.GetFullRedis().Decrement(key, value);
    }
 
    /// <inheritdoc/>
    public long Increment(string key, long value)
    {
        return _simpleRedis.GetFullRedis().Increment(key, value);
    }
 
    /// <inheritdoc/>
    public double Increment(string key, double value)
    {
        return _simpleRedis.GetFullRedis().Increment(key, value);
    }
 
    #endregion 高级操作
 
    #region 事务
 
    /// <inheritdoc/>
    public int Commit()
    {
        return _simpleRedis.GetFullRedis().Commit();
    }
 
    /// <inheritdoc/>
    public IDisposable AcquireLock(string key, int msTimeout)
    {
        return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout);
    }
 
    /// <inheritdoc/>
    public IDisposable AcquireLock(string key, int msTimeout, int msExpire, bool throwOnFailure)
    {
        return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout, msExpire, throwOnFailure);
    }
 
    #endregion 事务
}