From 81294af9096dcbabffdb06551363567c6d66e28c Mon Sep 17 00:00:00 2001 From: AzenKain Date: Sun, 24 May 2026 19:37:06 +0700 Subject: [PATCH] feat: implement geometry, battle replay, and entity repositories with caching support --- internal/repositories/battleReplayRepository.go | 8 ++------ internal/repositories/entityRepository.go | 4 +--- internal/repositories/geometryRepository.go | 9 ++------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/internal/repositories/battleReplayRepository.go b/internal/repositories/battleReplayRepository.go index 77a228e..05eed96 100644 --- a/internal/repositories/battleReplayRepository.go +++ b/internal/repositories/battleReplayRepository.go @@ -166,9 +166,7 @@ func (r *battleReplayRepository) GetByGeometryID(ctx context.Context, geometryID if len(itemToCache) > 0 { _ = r.c.MSet(ctx, itemToCache, constants.NormalCacheDuration) } - if len(ids) > 0 { - _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) - } + _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) return items, nil } @@ -233,9 +231,7 @@ func (r *battleReplayRepository) GetByProjectID(ctx context.Context, projectID p if len(itemToCache) > 0 { _ = r.c.MSet(ctx, itemToCache, constants.NormalCacheDuration) } - if len(ids) > 0 { - _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) - } + _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) return items, nil } diff --git a/internal/repositories/entityRepository.go b/internal/repositories/entityRepository.go index c58961b..5b8a39f 100644 --- a/internal/repositories/entityRepository.go +++ b/internal/repositories/entityRepository.go @@ -297,9 +297,7 @@ func (r *entityRepository) GetByProjectID(ctx context.Context, projectID pgtype. if len(entityToCache) > 0 { _ = r.c.MSet(ctx, entityToCache, constants.NormalCacheDuration) } - if len(ids) > 0 { - _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) - } + _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) return entities, nil } diff --git a/internal/repositories/geometryRepository.go b/internal/repositories/geometryRepository.go index 78a2ed4..2b76985 100644 --- a/internal/repositories/geometryRepository.go +++ b/internal/repositories/geometryRepository.go @@ -351,9 +351,7 @@ func (r *geometryRepository) GetByProjectID(ctx context.Context, projectID pgtyp if len(geometryToCache) > 0 { _ = r.c.MSet(ctx, geometryToCache, constants.NormalCacheDuration) } - if len(ids) > 0 { - _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) - } + _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) return geometries, nil } @@ -401,10 +399,7 @@ func (r *geometryRepository) GetGeometriesByBoundWith(ctx context.Context, bound if len(geometryToCache) > 0 { _ = r.c.MSet(ctx, geometryToCache, constants.NormalCacheDuration) } - if len(ids) > 0 { - _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) - } - + _ = r.c.Set(ctx, cacheKey, ids, constants.ListCacheDuration) return geometries, nil }