@@ -159,11 +159,12 @@ public override async Task<object> BaseGetAsync(string cacheKey, Type type, Canc
159
159
/// <returns>The async.</returns>
160
160
/// <param name="cacheKey">Cache key.</param>
161
161
/// <param name="cancellationToken">CancellationToken</param>
162
- public override async Task BaseRemoveAsync ( string cacheKey , CancellationToken cancellationToken = default )
162
+ public override Task BaseRemoveAsync ( string cacheKey , CancellationToken cancellationToken = default )
163
163
{
164
164
ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
165
165
166
- await Task . Run ( ( ) => { _cache . Remove ( cacheKey ) ; } , cancellationToken ) ;
166
+ _cache . Remove ( cacheKey ) ;
167
+ return Task . CompletedTask ;
167
168
}
168
169
169
170
/// <summary>
@@ -175,7 +176,7 @@ public override async Task BaseRemoveAsync(string cacheKey, CancellationToken ca
175
176
/// <param name="expiration">Expiration.</param>
176
177
/// <param name="cancellationToken">CancellationToken</param>
177
178
/// <typeparam name="T">The 1st type parameter.</typeparam>
178
- public override async Task BaseSetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration , CancellationToken cancellationToken = default )
179
+ public override Task BaseSetAsync < T > ( string cacheKey , T cacheValue , TimeSpan expiration , CancellationToken cancellationToken = default )
179
180
{
180
181
ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
181
182
ArgumentCheck . NotNull ( cacheValue , nameof ( cacheValue ) , _options . CacheNulls ) ;
@@ -187,12 +188,10 @@ public override async Task BaseSetAsync<T>(string cacheKey, T cacheValue, TimeSp
187
188
expiration = expiration . Add ( TimeSpan . FromSeconds ( addSec ) ) ;
188
189
}
189
190
190
- await Task . Run ( ( ) =>
191
- {
192
- //var valExpiration = expiration.Seconds <= 1 ? expiration : TimeSpan.FromSeconds(expiration.Seconds / 2);
193
- //var val = new CacheValue<T>(cacheValue, true, valExpiration);
194
- _cache . Set ( cacheKey , cacheValue , expiration ) ;
195
- } , cancellationToken ) ;
191
+ //var valExpiration = expiration.Seconds <= 1 ? expiration : TimeSpan.FromSeconds(expiration.Seconds / 2);
192
+ //var val = new CacheValue<T>(cacheValue, true, valExpiration);
193
+ _cache . Set ( cacheKey , cacheValue , expiration ) ;
194
+ return Task . CompletedTask ;
196
195
}
197
196
198
197
/// <summary>
@@ -201,11 +200,11 @@ await Task.Run(() =>
201
200
/// <returns>The async.</returns>
202
201
/// <param name="cacheKey">Cache key.</param>
203
202
/// <param name="cancellationToken">CancellationToken</param>
204
- public override async Task < bool > BaseExistsAsync ( string cacheKey , CancellationToken cancellationToken = default )
203
+ public override Task < bool > BaseExistsAsync ( string cacheKey , CancellationToken cancellationToken = default )
205
204
{
206
205
ArgumentCheck . NotNullOrWhiteSpace ( cacheKey , nameof ( cacheKey ) ) ;
207
206
208
- return await Task . FromResult ( _cache . Exists ( cacheKey ) ) ;
207
+ return Task . FromResult ( _cache . Exists ( cacheKey ) ) ;
209
208
}
210
209
211
210
/// <summary>
@@ -214,14 +213,15 @@ public override async Task<bool> BaseExistsAsync(string cacheKey, CancellationTo
214
213
/// <returns>The by prefix async.</returns>
215
214
/// <param name="prefix">Prefix.</param>
216
215
/// <param name="cancellationToken">CancellationToken</param>
217
- public override async Task BaseRemoveByPrefixAsync ( string prefix , CancellationToken cancellationToken = default )
216
+ public override Task BaseRemoveByPrefixAsync ( string prefix , CancellationToken cancellationToken = default )
218
217
{
219
218
ArgumentCheck . NotNullOrWhiteSpace ( prefix , nameof ( prefix ) ) ;
220
219
221
- var count = await Task . Run ( ( ) => _cache . RemoveByPrefix ( prefix ) , cancellationToken ) ;
220
+ var count = _cache . RemoveByPrefix ( prefix ) ;
222
221
223
222
if ( _options . EnableLogging )
224
223
_logger ? . LogInformation ( $ "RemoveByPrefixAsync : prefix = { prefix } , count = { count } ") ;
224
+ return Task . CompletedTask ;
225
225
}
226
226
227
227
/// <summary>
@@ -230,17 +230,18 @@ public override async Task BaseRemoveByPrefixAsync(string prefix, CancellationTo
230
230
/// <returns>The by prefix async.</returns>
231
231
/// <param name="pattern">Pattern.</param>
232
232
/// <param name="cancellationToken">CancellationToken</param>
233
- public override async Task BaseRemoveByPatternAsync ( string pattern , CancellationToken cancellationToken = default )
233
+ public override Task BaseRemoveByPatternAsync ( string pattern , CancellationToken cancellationToken = default )
234
234
{
235
235
ArgumentCheck . NotNullOrWhiteSpace ( pattern , nameof ( pattern ) ) ;
236
236
237
237
var searchPattern = this . ProcessSearchKeyPattern ( pattern ) ;
238
238
var searchKey = this . HandleSearchKeyPattern ( pattern ) ;
239
-
240
- var count = await Task . Run ( ( ) => _cache . RemoveByPattern ( searchKey , searchPattern ) , cancellationToken ) ;
239
+
240
+ var count = _cache . RemoveByPattern ( searchKey , searchPattern ) ;
241
241
242
242
if ( _options . EnableLogging )
243
243
_logger ? . LogInformation ( $ "BaseRemoveByPatternAsync : pattern = { pattern } , count = { count } ") ;
244
+ return Task . CompletedTask ;
244
245
}
245
246
246
247
/// <summary>
@@ -251,12 +252,13 @@ public override async Task BaseRemoveByPatternAsync(string pattern, Cancellation
251
252
/// <param name="expiration">Expiration.</param>
252
253
/// <param name="cancellationToken">CancellationToken</param>
253
254
/// <typeparam name="T">The 1st type parameter.</typeparam>
254
- public override async Task BaseSetAllAsync < T > ( IDictionary < string , T > values , TimeSpan expiration , CancellationToken cancellationToken = default )
255
+ public override Task BaseSetAllAsync < T > ( IDictionary < string , T > values , TimeSpan expiration , CancellationToken cancellationToken = default )
255
256
{
256
257
ArgumentCheck . NotNegativeOrZero ( expiration , nameof ( expiration ) ) ;
257
258
ArgumentCheck . NotNullAndCountGTZero ( values , nameof ( values ) ) ;
258
259
259
- await Task . Run ( ( ) => _cache . SetAll ( values , expiration ) , cancellationToken ) ;
260
+ _cache . SetAll ( values , expiration ) ;
261
+ return Task . CompletedTask ;
260
262
}
261
263
262
264
/// <summary>
@@ -266,16 +268,16 @@ public override async Task BaseSetAllAsync<T>(IDictionary<string, T> values, Tim
266
268
/// <param name="cacheKeys">Cache keys.</param>
267
269
/// <param name="cancellationToken">CancellationToken</param>
268
270
/// <typeparam name="T">The 1st type parameter.</typeparam>
269
- public override async Task < IDictionary < string , CacheValue < T > > > BaseGetAllAsync < T > ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
271
+ public override Task < IDictionary < string , CacheValue < T > > > BaseGetAllAsync < T > ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
270
272
{
271
273
ArgumentCheck . NotNullAndCountGTZero ( cacheKeys , nameof ( cacheKeys ) ) ;
272
274
273
275
if ( _options . EnableLogging )
274
276
_logger ? . LogInformation ( $ "GetAllAsync : cacheKeys = { string . Join ( "," , cacheKeys ) } ") ;
275
277
276
- return await Task . FromResult ( _cache . GetAll < T > ( cacheKeys ) ) ;
278
+ return Task . FromResult ( _cache . GetAll < T > ( cacheKeys ) ) ;
277
279
}
278
-
280
+
279
281
280
282
/// <summary>
281
283
/// Get all cacheKey by prefix async.
@@ -298,15 +300,15 @@ public override Task<IEnumerable<string>> BaseGetAllKeysByPrefixAsync(string pre
298
300
/// <param name="prefix">Prefix.</param>
299
301
/// <param name="cancellationToken">CancellationToken</param>
300
302
/// <typeparam name="T">The 1st type parameter.</typeparam>
301
- public override async Task < IDictionary < string , CacheValue < T > > > BaseGetByPrefixAsync < T > ( string prefix , CancellationToken cancellationToken = default )
303
+ public override Task < IDictionary < string , CacheValue < T > > > BaseGetByPrefixAsync < T > ( string prefix , CancellationToken cancellationToken = default )
302
304
{
303
305
ArgumentCheck . NotNullOrWhiteSpace ( prefix , nameof ( prefix ) ) ;
304
306
var map = new Dictionary < string , CacheValue < T > > ( ) ;
305
307
306
308
if ( _options . EnableLogging )
307
309
_logger ? . LogInformation ( $ "GetByPrefixAsync : prefix = { prefix } ") ;
308
310
309
- return await Task . FromResult ( _cache . GetByPrefix < T > ( prefix ) ) ;
311
+ return Task . FromResult ( _cache . GetByPrefix < T > ( prefix ) ) ;
310
312
}
311
313
312
314
/// <summary>
@@ -315,28 +317,29 @@ public override async Task<IDictionary<string, CacheValue<T>>> BaseGetByPrefixAs
315
317
/// <returns>The all async.</returns>
316
318
/// <param name="cacheKeys">Cache keys.</param>
317
319
/// <param name="cancellationToken">CancellationToken</param>
318
- public override async Task BaseRemoveAllAsync ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
320
+ public override Task BaseRemoveAllAsync ( IEnumerable < string > cacheKeys , CancellationToken cancellationToken = default )
319
321
{
320
322
ArgumentCheck . NotNullAndCountGTZero ( cacheKeys , nameof ( cacheKeys ) ) ;
321
323
322
324
if ( _options . EnableLogging )
323
325
_logger ? . LogInformation ( $ "RemoveAllAsync : cacheKeys = { string . Join ( "," , cacheKeys ) } ") ;
324
326
325
- await Task . Run ( ( ) => _cache . RemoveAll ( cacheKeys ) , cancellationToken ) ;
327
+ _cache . RemoveAll ( cacheKeys ) ;
328
+ return Task . CompletedTask ;
326
329
}
327
330
328
331
/// <summary>
329
332
/// Flush All Cached Item async.
330
333
/// </summary>
331
334
/// <returns>The async.</returns>
332
335
/// <param name="cancellationToken">CancellationToken</param>
333
- public override async Task BaseFlushAsync ( CancellationToken cancellationToken = default )
336
+ public override Task BaseFlushAsync ( CancellationToken cancellationToken = default )
334
337
{
335
338
if ( _options . EnableLogging )
336
339
_logger ? . LogInformation ( "FlushAsync" ) ;
337
340
338
341
_cache . Clear ( ) ;
339
- await Task . CompletedTask ;
342
+ return Task . CompletedTask ;
340
343
}
341
344
342
345
/// <summary>
0 commit comments