Skip to content

Commit f8c2367

Browse files
authored
Merge pull request #1180 from AndrewNikolin/master
Honour cache expiration from ctor if not passed explicitly
2 parents a820f3b + 2ede3ad commit f8c2367

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

RepoDb.Core/RepoDb/BaseRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ public IEnumerable<TEntity> ExecuteQuery(string commandText,
316316
object param = null,
317317
CommandType? commandType = null,
318318
string cacheKey = null,
319-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
319+
int? cacheItemExpiration = null,
320320
IDbTransaction transaction = null)
321321
{
322322
return DbRepository.ExecuteQuery<TEntity>(commandText: commandText,
323323
param: param,
324324
commandType: commandType,
325325
cacheKey: cacheKey,
326-
cacheItemExpiration: cacheItemExpiration,
326+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
327327
transaction: transaction);
328328
}
329329

@@ -354,15 +354,15 @@ public Task<IEnumerable<TEntity>> ExecuteQueryAsync(string commandText,
354354
object param = null,
355355
CommandType? commandType = null,
356356
string cacheKey = null,
357-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
357+
int? cacheItemExpiration = null,
358358
IDbTransaction transaction = null,
359359
CancellationToken cancellationToken = default)
360360
{
361361
return DbRepository.ExecuteQueryAsync<TEntity>(commandText: commandText,
362362
param: param,
363363
commandType: commandType,
364364
cacheKey: cacheKey,
365-
cacheItemExpiration: cacheItemExpiration,
365+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
366366
transaction: transaction,
367367
cancellationToken: cancellationToken);
368368
}

RepoDb.Core/RepoDb/DbRepository.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public IEnumerable<dynamic> ExecuteQuery(string commandText,
368368
object param = null,
369369
CommandType? commandType = null,
370370
string cacheKey = null,
371-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
371+
int? cacheItemExpiration = null,
372372
IDbTransaction transaction = null)
373373
{
374374
// Create a connection
@@ -381,7 +381,7 @@ public IEnumerable<dynamic> ExecuteQuery(string commandText,
381381
param: param,
382382
commandType: commandType,
383383
cacheKey: cacheKey,
384-
cacheItemExpiration: cacheItemExpiration,
384+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
385385
commandTimeout: CommandTimeout,
386386
transaction: transaction,
387387
cache: Cache);
@@ -420,7 +420,7 @@ public async Task<IEnumerable<dynamic>> ExecuteQueryAsync(string commandText,
420420
object param = null,
421421
CommandType? commandType = null,
422422
string cacheKey = null,
423-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
423+
int? cacheItemExpiration = null,
424424
IDbTransaction transaction = null,
425425
CancellationToken cancellationToken = default)
426426
{
@@ -434,7 +434,7 @@ public async Task<IEnumerable<dynamic>> ExecuteQueryAsync(string commandText,
434434
param: param,
435435
commandType: commandType,
436436
cacheKey: cacheKey,
437-
cacheItemExpiration: cacheItemExpiration,
437+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
438438
commandTimeout: CommandTimeout,
439439
transaction: transaction,
440440
cache: Cache,
@@ -474,7 +474,7 @@ public IEnumerable<TEntity> ExecuteQuery<TEntity>(string commandText,
474474
object param = null,
475475
CommandType? commandType = null,
476476
string cacheKey = null,
477-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
477+
int? cacheItemExpiration = null,
478478
IDbTransaction transaction = null)
479479
where TEntity : class
480480
{
@@ -488,7 +488,7 @@ public IEnumerable<TEntity> ExecuteQuery<TEntity>(string commandText,
488488
param: param,
489489
commandType: commandType,
490490
cacheKey: cacheKey,
491-
cacheItemExpiration: cacheItemExpiration,
491+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
492492
commandTimeout: CommandTimeout,
493493
transaction: transaction,
494494
cache: Cache);
@@ -528,7 +528,7 @@ public async Task<IEnumerable<TEntity>> ExecuteQueryAsync<TEntity>(string comman
528528
object param = null,
529529
CommandType? commandType = null,
530530
string cacheKey = null,
531-
int? cacheItemExpiration = Constant.DefaultCacheItemExpirationInMinutes,
531+
int? cacheItemExpiration = null,
532532
IDbTransaction transaction = null,
533533
CancellationToken cancellationToken = default)
534534
where TEntity : class
@@ -543,7 +543,7 @@ public async Task<IEnumerable<TEntity>> ExecuteQueryAsync<TEntity>(string comman
543543
param: param,
544544
commandType: commandType,
545545
cacheKey: cacheKey,
546-
cacheItemExpiration: cacheItemExpiration,
546+
cacheItemExpiration: cacheItemExpiration ?? CacheItemExpiration,
547547
commandTimeout: CommandTimeout,
548548
transaction: transaction,
549549
cache: Cache,

0 commit comments

Comments
 (0)