Skip to content

Commit

Permalink
optimize: cache in episode save (#723)
Browse files Browse the repository at this point in the history
* build: upgrade to v0.19.2

* optimize: cache in episode save.

* docs: update CHANGELOG.MD
  • Loading branch information
chivehao authored Nov 10, 2024
1 parent 425e9e7 commit 0196f52
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

更新日志文档,版本顺序从新到旧,最新版本在最前(上)面。

# 0.19.2

## 优化

- 优化剧集保存时的缓存配置

# 0.19.1

## 问题修复
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.19.0
version=0.19.2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.r2dbc.core.DatabaseClient;
Expand Down Expand Up @@ -48,7 +47,12 @@ public DefaultEpisodeService(EpisodeRepository episodeRepository,


@Override
@CachePut(value = "episodeWithName", key = "#episode.name")
@CacheEvict(value = {"episodeWithId", "episodesWithSubjectId",
"episodeWithSubjectIdAndGroupAndSeqAndName",
"episodesWithSubjectIdAndGroupAndSeq",
"episodeCountWithSubjectId", "episodeMatchingCountWithSubjectId",
"episodesWithId", "episodeWithName"
}, allEntries = true)
public Mono<Episode> save(Episode episode) {
Assert.notNull(episode, "episode must not be null");
Long episodeId = episode.getId();
Expand Down Expand Up @@ -166,8 +170,7 @@ public Flux<EpisodeResource> findResourcesById(Long episodeId) {
"episodesWithSubjectIdAndGroupAndSeq",
"episodeCountWithSubjectId", "episodeMatchingCountWithSubjectId",
"episodesWithId", "episodeWithName"
},
allEntries = true)
}, allEntries = true)
public Flux<Episode> updateEpisodesWithSubjectId(Long subjectId, List<Episode> episodes) {
Assert.isTrue(subjectId >= 0, "'subjectId' must >= 0.");
Assert.notNull(episodes, "'episodes' must not be null.");
Expand Down

0 comments on commit 0196f52

Please sign in to comment.