@@ -11,7 +11,7 @@ import org.typelevel.log4cats.slf4j.Slf4jFactory as Log4CatsSlf4jFactory
1111import org .typelevel .otel4s .trace .Tracer
1212import com .github .benmanes .caffeine .cache .{Cache as CaffeineCache , Caffeine }
1313import net .yoshinorin .qualtet .auth .{AuthService , Jwt , KeyPair }
14- import net .yoshinorin .qualtet .cache .{ CacheRepository , InMemoryCache }
14+ import net .yoshinorin .qualtet .cache .CacheRepository
1515import net .yoshinorin .qualtet .config .ApplicationConfig
1616import net .yoshinorin .qualtet .domains .{ArticlesPagination , FeedsPagination , Limit , Page , PaginationOps , PaginationRequestModel , TagsPagination }
1717import net .yoshinorin .qualtet .domains .archives .{ArchiveRepository , ArchiveRepositoryAdapter , ArchiveService }
@@ -98,7 +98,10 @@ class Modules(tx: Transactor[IO], maybeTracer: Option[Tracer[IO]] = None) {
9898 val contentTypeRepositoryAdapter : ContentTypeRepositoryAdapter [ConnectionIO ] = new ContentTypeRepositoryAdapter (contentTypeRepository)
9999 val contentTypeCaffeinCache : CaffeineCache [String , ContentType ] =
100100 Caffeine .newBuilder().expireAfterAccess(config.cache.contentType, TimeUnit .SECONDS ).build[String , ContentType ]
101- val contentTypeCache : CacheRepository [IO , String , ContentType ] = new InMemoryCache [IO , String , ContentType ](contentTypeCaffeinCache)
101+ val contentTypeCache : CacheRepository [IO , String , ContentType ] = {
102+ given CaffeineCache [String , ContentType ] = contentTypeCaffeinCache
103+ summon[CacheRepository [IO , String , ContentType ]]
104+ }
102105 val contentTypeService = new ContentTypeService [IO , ConnectionIO ](contentTypeRepositoryAdapter, contentTypeCache)
103106
104107 val robotsRepository : RobotsRepository [ConnectionIO ] = summon[RobotsRepository [ConnectionIO ]]
@@ -113,7 +116,10 @@ class Modules(tx: Transactor[IO], maybeTracer: Option[Tracer[IO]] = None) {
113116 val tagRepository : TagRepository [ConnectionIO ] = summon[TagRepository [ConnectionIO ]]
114117 val tagsCaffeinCache : CaffeineCache [String , Seq [TagResponseModel ]] =
115118 Caffeine .newBuilder().expireAfterAccess(config.cache.tags, TimeUnit .SECONDS ).build[String , Seq [TagResponseModel ]]
116- val tagsCache : CacheRepository [IO , String , Seq [TagResponseModel ]] = new InMemoryCache [IO , String , Seq [TagResponseModel ]](tagsCaffeinCache)
119+ val tagsCache : CacheRepository [IO , String , Seq [TagResponseModel ]] = {
120+ given CaffeineCache [String , Seq [TagResponseModel ]] = tagsCaffeinCache
121+ summon[CacheRepository [IO , String , Seq [TagResponseModel ]]]
122+ }
117123 val tagRepositoryAdapter : TagRepositoryAdapter [ConnectionIO ] = new TagRepositoryAdapter [ConnectionIO ](tagRepository)
118124 val tagService = new TagService [IO , ConnectionIO ](tagRepositoryAdapter, tagsCache, contentTaggingRepositoryAdapter)
119125
@@ -159,14 +165,20 @@ class Modules(tx: Transactor[IO], maybeTracer: Option[Tracer[IO]] = None) {
159165 val sitemapRepository : SitemapsRepository [ConnectionIO ] = summon[SitemapsRepository [ConnectionIO ]]
160166 val sitemapCaffeinCache : CaffeineCache [String , Seq [Url ]] =
161167 Caffeine .newBuilder().expireAfterAccess(config.cache.sitemap, TimeUnit .SECONDS ).build[String , Seq [Url ]]
162- val sitemapCache : CacheRepository [IO , String , Seq [Url ]] = new InMemoryCache [IO , String , Seq [Url ]](sitemapCaffeinCache)
168+ val sitemapCache : CacheRepository [IO , String , Seq [Url ]] = {
169+ given CaffeineCache [String , Seq [Url ]] = sitemapCaffeinCache
170+ summon[CacheRepository [IO , String , Seq [Url ]]]
171+ }
163172 val sitemapRepositoryAdapter : SitemapRepositoryAdapter [ConnectionIO ] = new SitemapRepositoryAdapter [ConnectionIO ](sitemapRepository)
164173 val sitemapService = new SitemapService [IO , ConnectionIO ](sitemapRepositoryAdapter, sitemapCache)
165174
166175 val feedsPaginationOps = summon[PaginationOps [FeedsPagination ]]
167176 val feedCaffeinCache : CaffeineCache [String , ArticleWithCountResponseModel ] =
168177 Caffeine .newBuilder().expireAfterAccess(config.cache.feed, TimeUnit .SECONDS ).build[String , ArticleWithCountResponseModel ]
169- val feedCache : CacheRepository [IO , String , ArticleWithCountResponseModel ] = new InMemoryCache [IO , String , ArticleWithCountResponseModel ](feedCaffeinCache)
178+ val feedCache : CacheRepository [IO , String , ArticleWithCountResponseModel ] = {
179+ given CaffeineCache [String , ArticleWithCountResponseModel ] = feedCaffeinCache
180+ summon[CacheRepository [IO , String , ArticleWithCountResponseModel ]]
181+ }
170182 val feedService = new FeedService [IO , ConnectionIO ](
171183 feedsPaginationOps.make(PaginationRequestModel (Option (Page (1 )), Option (Limit (config.feed.limit)), None )),
172184 feedCache,
0 commit comments