22{
33 using System ;
44 using System . Collections . Generic ;
5+ using System . Threading ;
56 using System . Threading . Tasks ;
67 using EasyCaching . Core ;
78 using global ::CSRedis ;
@@ -14,32 +15,35 @@ public partial class DefaultCSRedisCachingProvider : EasyCachingAbstractProvider
1415 /// </summary>
1516 /// <returns>The async.</returns>
1617 /// <param name="cacheKey">Cache key.</param>
17- public override async Task < bool > BaseExistsAsync ( string cacheKey )
18+ /// <param name="cancellationToken">CancellationToken</param>
19+ public override async Task < bool > BaseExistsAsync ( string cacheKey , CancellationToken cancellationToken = default )
1820 {
1921 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
2022
2123 return await _cache . ExistsAsync ( cacheKey ) ;
2224 }
23-
25+
2426 /// <summary>
2527 /// Flushs the async.
2628 /// </summary>
29+ /// <param name="cancellationToken">CancellationToken</param>
2730 /// <returns>The async.</returns>
28- public override async Task BaseFlushAsync ( )
31+ public override async Task BaseFlushAsync ( CancellationToken cancellationToken = default )
2932 {
3033 if ( _options . EnableLogging )
3134 _logger ? . LogInformation ( "Redis -- FlushAsync" ) ;
3235
3336 await _cache . NodesServerManager . FlushDbAsync ( ) ;
3437 }
35-
38+
3639 /// <summary>
3740 /// Gets all async.
3841 /// </summary>
3942 /// <returns>The all async.</returns>
4043 /// <param name="cacheKeys">Cache keys.</param>
44+ /// <param name="cancellationToken">CancellationToken</param>
4145 /// <typeparam name="T">The 1st type parameter.</typeparam>
42- public override async Task < IDictionary < string , CacheValue < T > > > BaseGetAllAsync < T > ( IEnumerable < string > cacheKeys )
46+ public override async Task < IDictionary < string , CacheValue < T > > > BaseGetAllAsync < T > ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
4347 {
4448 ArgumentCheck . NotNullAndCountGTZero ( cacheKeys , nameof ( cacheKeys ) ) ;
4549
@@ -67,8 +71,9 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetAllAsync<T
6771 /// <param name="cacheKey">Cache key.</param>
6872 /// <param name="dataRetriever">Data retriever.</param>
6973 /// <param name="expiration">Expiration.</param>
74+ /// <param name="cancellationToken">CancellationToken</param>
7075 /// <typeparam name="T">The 1st type parameter.</typeparam>
71- public override async Task < CacheValue < T > > BaseGetAsync < T > ( string cacheKey , Func < Task < T > > dataRetriever , TimeSpan expiration )
76+ public override async Task < CacheValue < T > > BaseGetAsync < T > ( string cacheKey , Func < Task < T > > dataRetriever , TimeSpan expiration , CancellationToken cancellationToken = default )
7277 {
7378 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
7479 ArgumentCheck . NotNegativeOrZero ( expiration , nameof ( expiration ) ) ;
@@ -120,7 +125,8 @@ public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey, Func<
120125 /// <returns>The async.</returns>
121126 /// <param name="cacheKey">Cache key.</param>
122127 /// <param name="type">Object Type.</param>
123- public override async Task < object > BaseGetAsync ( string cacheKey , Type type )
128+ /// <param name="cancellationToken">CancellationToken</param>
129+ public override async Task < object > BaseGetAsync ( string cacheKey , Type type , CancellationToken cancellationToken = default )
124130 {
125131 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
126132
@@ -151,8 +157,9 @@ public override async Task<object> BaseGetAsync(string cacheKey, Type type)
151157 /// </summary>
152158 /// <returns>The async.</returns>
153159 /// <param name="cacheKey">Cache key.</param>
160+ /// <param name="cancellationToken">CancellationToken</param>
154161 /// <typeparam name="T">The 1st type parameter.</typeparam>
155- public override async Task < CacheValue < T > > BaseGetAsync < T > ( string cacheKey )
162+ public override async Task < CacheValue < T > > BaseGetAsync < T > ( string cacheKey , CancellationToken cancellationToken = default )
156163 {
157164 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
158165
@@ -183,7 +190,8 @@ public override async Task<CacheValue<T>> BaseGetAsync<T>(string cacheKey)
183190 /// </summary>
184191 /// <returns>The count.</returns>
185192 /// <param name="prefix">Prefix.</param>
186- public override Task < int > BaseGetCountAsync ( string prefix = "" )
193+ /// <param name="cancellationToken">CancellationToken</param>
194+ public override Task < int > BaseGetCountAsync ( string prefix = "" , CancellationToken cancellationToken = default )
187195 {
188196 if ( string . IsNullOrWhiteSpace ( prefix ) )
189197 {
@@ -207,8 +215,9 @@ public override Task<int> BaseGetCountAsync(string prefix = "")
207215 /// </summary>
208216 /// <returns>The by prefix async.</returns>
209217 /// <param name="prefix">Prefix.</param>
218+ /// <param name="cancellationToken">CancellationToken</param>
210219 /// <typeparam name="T">The 1st type parameter.</typeparam>
211- public override async Task < IDictionary < string , CacheValue < T > > > BaseGetByPrefixAsync < T > ( string prefix )
220+ public override async Task < IDictionary < string , CacheValue < T > > > BaseGetByPrefixAsync < T > ( string prefix , CancellationToken cancellationToken = default )
212221 {
213222 ArgumentCheck . NotNullOrWhiteSpace ( prefix , nameof ( prefix ) ) ;
214223
@@ -229,13 +238,14 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAs
229238
230239 return result ;
231240 }
232-
241+
233242 /// <summary>
234243 /// Removes all async.
235244 /// </summary>
236245 /// <returns>The all async.</returns>
237246 /// <param name="cacheKeys">Cache keys.</param>
238- public override async Task BaseRemoveAllAsync ( IEnumerable < string > cacheKeys )
247+ /// <param name="cancellationToken">CancellationToken</param>
248+ public override async Task BaseRemoveAllAsync ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
239249 {
240250 ArgumentCheck . NotNullAndCountGTZero ( cacheKeys , nameof ( cacheKeys ) ) ;
241251
@@ -254,19 +264,21 @@ public override async Task BaseRemoveAllAsync(IEnumerable<string> cacheKeys)
254264 /// </summary>
255265 /// <returns>The async.</returns>
256266 /// <param name="cacheKey">Cache key.</param>
257- public override async Task BaseRemoveAsync ( string cacheKey )
267+ /// <param name="cancellationToken">CancellationToken</param>
268+ public override async Task BaseRemoveAsync ( string cacheKey , CancellationToken cancellationToken = default )
258269 {
259270 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
260271
261272 await _cache . DelAsync ( cacheKey ) ;
262- }
273+ }
263274
264275 /// <summary>
265276 /// Removes the by prefix async.
266277 /// </summary>
267278 /// <returns>The by prefix async.</returns>
268279 /// <param name="prefix">Prefix.</param>
269- public override async Task BaseRemoveByPrefixAsync ( string prefix )
280+ /// <param name="cancellationToken">CancellationToken</param>
281+ public override async Task BaseRemoveByPrefixAsync ( string prefix , CancellationToken cancellationToken = default )
270282 {
271283 ArgumentCheck . NotNullOrWhiteSpace ( prefix , nameof ( prefix ) ) ;
272284
@@ -293,8 +305,9 @@ public override async Task BaseRemoveByPrefixAsync(string prefix)
293305 /// <returns>The all async.</returns>
294306 /// <param name="value">Value.</param>
295307 /// <param name="expiration">Expiration.</param>
308+ /// <param name="cancellationToken">CancellationToken</param>
296309 /// <typeparam name="T">The 1st type parameter.</typeparam>
297- public override async Task BaseSetAllAsync < T > ( IDictionary < string , T > value , TimeSpan expiration )
310+ public override async Task BaseSetAllAsync < T > ( IDictionary < string , T > value , TimeSpan expiration , CancellationToken cancellationToken = default )
298311 {
299312 //whether to use pipe based on redis mode
300313 var tasks = new List < Task < bool > > ( ) ;
@@ -320,8 +333,9 @@ public override async Task BaseSetAllAsync<T>(IDictionary<string, T> value, Time
320333 /// <param name="cacheKey">Cache key.</param>
321334 /// <param name="cacheValue">Cache value.</param>
322335 /// <param name="expiration">Expiration.</param>
336+ /// <param name="cancellationToken">CancellationToken</param>
323337 /// <typeparam name="T">The 1st type parameter.</typeparam>
324- public override async Task BaseSetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration )
338+ public override async Task BaseSetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration , CancellationToken cancellationToken = default )
325339 {
326340 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
327341 ArgumentCheck . NotNull ( cacheValue , nameof ( cacheValue ) , _options . CacheNulls ) ;
@@ -349,8 +363,9 @@ await _cache.SetAsync(
349363 /// <param name="cacheKey">Cache key.</param>
350364 /// <param name="cacheValue">Cache value.</param>
351365 /// <param name="expiration">Expiration.</param>
366+ /// <param name="cancellationToken">CancellationToken</param>
352367 /// <typeparam name="T">The 1st type parameter.</typeparam>
353- public override async Task < bool > BaseTrySetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration )
368+ public override async Task < bool > BaseTrySetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration , CancellationToken cancellationToken = default )
354369 {
355370 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
356371 ArgumentCheck . NotNull ( cacheValue , nameof ( cacheValue ) , _options . CacheNulls ) ;
@@ -374,8 +389,9 @@ public override async Task<bool> BaseTrySetAsync<T>(string cacheKey, T cacheValu
374389 /// Get the expiration of cache key async
375390 /// </summary>
376391 /// <param name="cacheKey">cache key</param>
392+ /// <param name="cancellationToken">CancellationToken</param>
377393 /// <returns>expiration</returns>
378- public override async Task < TimeSpan > BaseGetExpirationAsync ( string cacheKey )
394+ public override async Task < TimeSpan > BaseGetExpirationAsync ( string cacheKey , CancellationToken cancellationToken = default )
379395 {
380396 ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
381397
0 commit comments