-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cache): evict clan cache after changes to entity/related entities
Closes #812
- Loading branch information
1 parent
91159bf
commit fbfbd04
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/faforever/api/data/listeners/ClanChangeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.faforever.api.data.listeners; | ||
|
||
import com.faforever.api.data.domain.Clan; | ||
|
||
import jakarta.persistence.PostRemove; | ||
import jakarta.persistence.PostUpdate; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class ClanChangeListener { | ||
|
||
@CacheEvict(cacheNames = Clan.TYPE_NAME, allEntries = true) | ||
@PostUpdate | ||
@PostRemove | ||
public void clanChanged(Clan clan) { | ||
log.debug("Clan cache evicted, due to change on Clan with id: {}", clan.getId()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/faforever/api/data/listeners/ClanMembershipChangeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.faforever.api.data.listeners; | ||
|
||
import com.faforever.api.data.domain.Clan; | ||
import com.faforever.api.data.domain.ClanMembership; | ||
|
||
import jakarta.persistence.PostPersist; | ||
import jakarta.persistence.PostRemove; | ||
import jakarta.persistence.PostUpdate; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.cache.annotation.CacheEvict; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Slf4j | ||
public class ClanMembershipChangeListener { | ||
|
||
@CacheEvict(cacheNames = Clan.TYPE_NAME, allEntries = true) | ||
@PostUpdate | ||
@PostRemove | ||
@PostPersist | ||
public void clanMembershipChanged(ClanMembership clanMembership) { | ||
log.debug("Clan cache evicted, due to change on ClanMembership with id: {}", | ||
clanMembership.getId()); | ||
} | ||
} |