From a9e1d0e45da434c9a350c09c469af5ac42c10467 Mon Sep 17 00:00:00 2001 From: Olivier Fuxet Date: Fri, 22 Nov 2024 18:31:02 +0100 Subject: [PATCH] Remove query cache --- bootstrap/src/main/resources/application.yaml | 9 --- bootstrap/src/main/resources/ehcache.xml | 73 ------------------- .../src/test/resources/application-it.yaml | 6 -- pom.xml | 11 --- read-api/pom.xml | 13 ---- .../api/read/cache/JpaCacheEventListener.java | 25 ------- .../api/read/cache/QueryCacheM.java | 18 ----- .../api/read/cache/QueryCacheS.java | 18 ----- .../api/read/cache/QueryCacheXS.java | 18 ----- .../repositories/BannerReadRepository.java | 3 - .../ContributionReadRepository.java | 2 - .../ProjectContributorQueryRepository.java | 2 - .../repositories/ProjectReadRepository.java | 3 - .../repositories/ProjectsPageRepository.java | 2 - 14 files changed, 203 deletions(-) delete mode 100644 bootstrap/src/main/resources/ehcache.xml delete mode 100644 read-api/src/main/java/onlydust/com/marketplace/api/read/cache/JpaCacheEventListener.java delete mode 100644 read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheM.java delete mode 100644 read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheS.java delete mode 100644 read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheXS.java diff --git a/bootstrap/src/main/resources/application.yaml b/bootstrap/src/main/resources/application.yaml index 06e6ffe10..c9ffd92e1 100644 --- a/bootstrap/src/main/resources/application.yaml +++ b/bootstrap/src/main/resources/application.yaml @@ -82,15 +82,6 @@ spring: database-platform: org.hibernate.dialect.PostgreSQLDialect properties: hibernate: - cache: - region.factory_class: org.hibernate.cache.jcache.internal.JCacheRegionFactory - use_second_level_cache: false - use_query_cache: true - javax: - cache: - provider: org.ehcache.jsr107.EhcacheCachingProvider - uri: classpath:ehcache.xml - missing_cache_strategy: fail query: in_clause_parameter_padding: true event: diff --git a/bootstrap/src/main/resources/ehcache.xml b/bootstrap/src/main/resources/ehcache.xml deleted file mode 100644 index 6d3b46447..000000000 --- a/bootstrap/src/main/resources/ehcache.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - 1 - - - - onlydust.com.marketplace.api.read.cache.JpaCacheEventListener - ASYNCHRONOUS - ORDERED - CREATED - EVICTED - EXPIRED - REMOVED - UPDATED - - - - 1000 - - - - - - 5 - - - - onlydust.com.marketplace.api.read.cache.JpaCacheEventListener - ASYNCHRONOUS - ORDERED - CREATED - EVICTED - EXPIRED - REMOVED - UPDATED - - - - 1000 - - - - - - 30 - - - - onlydust.com.marketplace.api.read.cache.JpaCacheEventListener - ASYNCHRONOUS - ORDERED - CREATED - EVICTED - EXPIRED - REMOVED - UPDATED - - - - 1000 - - - - - - - - \ No newline at end of file diff --git a/bootstrap/src/test/resources/application-it.yaml b/bootstrap/src/test/resources/application-it.yaml index e35e1ffcb..4c6dfa5c4 100644 --- a/bootstrap/src/test/resources/application-it.yaml +++ b/bootstrap/src/test/resources/application-it.yaml @@ -142,12 +142,6 @@ spring: maxLifetime: 60000 maximumPoolSize: 10 minimumIdle: 1 - jpa: - properties: - hibernate: - cache: - use_second_level_cache: false - use_query_cache: false decorator: datasource: datasource-proxy: diff --git a/pom.xml b/pom.xml index 652fb0673..ef2ca1774 100644 --- a/pom.xml +++ b/pom.xml @@ -209,17 +209,6 @@ dd-trace-api 1.40.0 - - org.ehcache - ehcache - 3.10.8 - jakarta - - - org.hibernate - hibernate-jcache - 6.4.4.Final - diff --git a/read-api/pom.xml b/read-api/pom.xml index df81e5226..b05ecb8fd 100644 --- a/read-api/pom.xml +++ b/read-api/pom.xml @@ -70,18 +70,5 @@ com.fasterxml.jackson.datatype jackson-datatype-jsr310 - - org.springframework - spring-context-support - - - org.ehcache - ehcache - jakarta - - - org.hibernate - hibernate-jcache - \ No newline at end of file diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/JpaCacheEventListener.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/JpaCacheEventListener.java deleted file mode 100644 index 6a67e80b5..000000000 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/JpaCacheEventListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package onlydust.com.marketplace.api.read.cache; - - -import lombok.extern.slf4j.Slf4j; -import org.ehcache.event.CacheEvent; -import org.ehcache.event.CacheEventListener; -import org.springframework.stereotype.Component; - - -@Slf4j -@Component -public class JpaCacheEventListener implements CacheEventListener { - - @Override - public void onEvent(CacheEvent event) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug( - "{ type: {}, key: {} }", - event.getType(), - event.getKey() - ); - } - } - -} diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheM.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheM.java deleted file mode 100644 index 7b33901e7..000000000 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheM.java +++ /dev/null @@ -1,18 +0,0 @@ -package onlydust.com.marketplace.api.read.cache; - -import jakarta.persistence.QueryHint; -import org.springframework.data.jpa.repository.QueryHints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static org.hibernate.annotations.QueryHints.CACHEABLE; -import static org.hibernate.annotations.QueryHints.CACHE_REGION; - -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@QueryHints({@QueryHint(name = CACHEABLE, value = "true"), @QueryHint(name = CACHE_REGION, value = "queryM")}) -public @interface QueryCacheM { -} diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheS.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheS.java deleted file mode 100644 index bae362f9e..000000000 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheS.java +++ /dev/null @@ -1,18 +0,0 @@ -package onlydust.com.marketplace.api.read.cache; - -import jakarta.persistence.QueryHint; -import org.springframework.data.jpa.repository.QueryHints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static org.hibernate.annotations.QueryHints.CACHEABLE; -import static org.hibernate.annotations.QueryHints.CACHE_REGION; - -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@QueryHints({@QueryHint(name = CACHEABLE, value = "true"), @QueryHint(name = CACHE_REGION, value = "queryS")}) -public @interface QueryCacheS { -} diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheXS.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheXS.java deleted file mode 100644 index c2c075ead..000000000 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/cache/QueryCacheXS.java +++ /dev/null @@ -1,18 +0,0 @@ -package onlydust.com.marketplace.api.read.cache; - -import jakarta.persistence.QueryHint; -import org.springframework.data.jpa.repository.QueryHints; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import static org.hibernate.annotations.QueryHints.CACHEABLE; -import static org.hibernate.annotations.QueryHints.CACHE_REGION; - -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@QueryHints({@QueryHint(name = CACHEABLE, value = "true"), @QueryHint(name = CACHE_REGION, value = "queryXS")}) -public @interface QueryCacheXS { -} diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/BannerReadRepository.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/BannerReadRepository.java index b2ef68260..611c1d7e8 100644 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/BannerReadRepository.java +++ b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/BannerReadRepository.java @@ -1,6 +1,5 @@ package onlydust.com.marketplace.api.read.repositories; -import onlydust.com.marketplace.api.read.cache.QueryCacheS; import onlydust.com.marketplace.api.read.entities.BannerReadEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -26,7 +25,6 @@ public interface BannerReadRepository extends Repository AND c.userId = :userId )) """) - @QueryCacheS Optional findMyFirstVisibleBanner(UUID userId); @Query(""" @@ -34,7 +32,6 @@ public interface BannerReadRepository extends Repository FROM BannerReadEntity b WHERE b.visible = true """) - @QueryCacheS Optional findFirstVisibleBanner(); diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ContributionReadRepository.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ContributionReadRepository.java index 78d050920..fc31bb18d 100644 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ContributionReadRepository.java +++ b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ContributionReadRepository.java @@ -5,7 +5,6 @@ import onlydust.com.marketplace.api.contract.model.ContributionsSortEnum; import onlydust.com.marketplace.api.contract.model.DataSourceEnum; import onlydust.com.marketplace.api.contract.model.SortDirection; -import onlydust.com.marketplace.api.read.cache.QueryCacheS; import onlydust.com.marketplace.api.read.entities.bi.ContributionReadEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -75,7 +74,6 @@ left join contributor_project_contributor_labels cpcl on coalesce(:projectContri ccd.contribution_uuid, rd.contribution_uuid """, nativeQuery = true) - @QueryCacheS Page findAll(ZonedDateTime fromDate, ZonedDateTime toDate, @NonNull Boolean onlyOnlyDustData, diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectContributorQueryRepository.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectContributorQueryRepository.java index 441bf7129..7b43d3383 100644 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectContributorQueryRepository.java +++ b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectContributorQueryRepository.java @@ -1,6 +1,5 @@ package onlydust.com.marketplace.api.read.repositories; -import onlydust.com.marketplace.api.read.cache.QueryCacheM; import onlydust.com.marketplace.api.read.entities.project.ProjectContributorsQueryEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -107,7 +106,6 @@ select count(ga.id) and (:login is null or ga.login ilike '%' || :login || '%') and (hc.contributor_github_user_id is null or :showHidden) """, nativeQuery = true) - @QueryCacheM Page findProjectContributors(final UUID projectId, final String login, final UUID projectLeadId, diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectReadRepository.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectReadRepository.java index b05f3b9dd..31e54d20e 100644 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectReadRepository.java +++ b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectReadRepository.java @@ -1,6 +1,5 @@ package onlydust.com.marketplace.api.read.repositories; -import onlydust.com.marketplace.api.read.cache.QueryCacheXS; import onlydust.com.marketplace.api.read.entities.project.ProjectReadEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -12,10 +11,8 @@ public interface ProjectReadRepository extends Repository { - @QueryCacheXS Optional findById(UUID id); - @QueryCacheXS Optional findBySlug(String slug); @Query(""" diff --git a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectsPageRepository.java b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectsPageRepository.java index 204042f11..19ff33350 100644 --- a/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectsPageRepository.java +++ b/read-api/src/main/java/onlydust/com/marketplace/api/read/repositories/ProjectsPageRepository.java @@ -1,6 +1,5 @@ package onlydust.com.marketplace.api.read.repositories; -import onlydust.com.marketplace.api.read.cache.QueryCacheM; import onlydust.com.marketplace.api.read.entities.project.ProjectPageItemQueryEntity; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -63,7 +62,6 @@ LEFT JOIN LATERAL ( cast(:hasGoodFirstIssues as boolean) is false and pcd.good_first_issue_count = 0) and (cast(:search as text) is null or p.search ilike '%' || cast(:search as text) || '%') """, nativeQuery = true) - @QueryCacheM Page findAll(UUID userId, Boolean mine, String search,