Skip to content

Commit 327fa3b

Browse files
committed
fix: various fixes
1 parent 91aeaef commit 327fa3b

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/ByteSync.Functions/Helpers/Loaders/DependencyInjectionLoader.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ private static void RegisterServerCommonAssembly(ContainerBuilder builder)
2525
.Where(t => t.Name.EndsWith("Repository"))
2626
.InstancePerLifetimeScope()
2727
.AsImplementedInterfaces();
28+
29+
var genericRepositoryTypes = executingAssembly.GetTypes()
30+
.Where(t => t.Name.Contains("Repository`") && t.IsGenericTypeDefinition && !t.IsInterface);
31+
32+
foreach (var genericType in genericRepositoryTypes)
33+
{
34+
builder.RegisterGeneric(genericType)
35+
.AsImplementedInterfaces()
36+
.AsSelf()
37+
.InstancePerLifetimeScope();
38+
}
2839

2940
builder.RegisterAssemblyTypes(executingAssembly)
3041
.Where(t => t.Name.EndsWith("Service"))

src/ByteSync.ServerCommon/Interfaces/Repositories/ICacheRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ByteSync.ServerCommon.Interfaces.Repositories;
66

77
public interface ICacheRepository<T> where T : class
88
{
9-
Task<T?> Get(CacheKey cacheKey, ITransaction? transaction = null);
9+
Task<T?> Get(CacheKey cacheKey);
1010

1111
Task<UpdateEntityResult<T>> Save(CacheKey cacheKey, T element, ITransaction? transaction = null, IRedLock? redisLock = null);
1212

src/ByteSync.ServerCommon/Repositories/CacheRepository.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public CacheRepository(IRedisInfrastructureService redisInfrastructureService)
1818
_redisInfrastructureService = redisInfrastructureService;
1919
}
2020

21-
public async Task<T?> Get(CacheKey cacheKey, ITransaction? transaction = null)
21+
public async Task<T?> Get(CacheKey cacheKey)
2222
{
23-
IDatabaseAsync database = _redisInfrastructureService.GetDatabase(transaction);
23+
IDatabaseAsync database = _redisInfrastructureService.GetDatabase();
2424
string? serializedElement = await database.StringGetAsync(cacheKey.Value);
2525

2626
if (serializedElement.IsNullOrEmpty())
@@ -59,7 +59,7 @@ public async Task<UpdateEntityResult<T>> Update(CacheKey cacheKey, Func<T, bool>
5959

6060
try
6161
{
62-
var cachedElement = await Get(cacheKey, transaction);
62+
var cachedElement = await Get(cacheKey);
6363

6464
if (cachedElement == null)
6565
{
@@ -93,7 +93,7 @@ public async Task<UpdateEntityResult<T>> AddOrUpdate(CacheKey cacheKey, Func<T?,
9393

9494
await using var redisLock = await _redisInfrastructureService.AcquireLockAsync(cacheKey);
9595

96-
var cachedElement = await Get(cacheKey, transaction);
96+
var cachedElement = await Get(cacheKey);
9797
var createdOrUpdatedElement = handler.Invoke(cachedElement);
9898

9999
if (createdOrUpdatedElement == null)

0 commit comments

Comments
 (0)