fix: complete cache consistency implementation

Phase 6: Cache Consistency Fix (Google Engineer Approach)
- Add @CacheEvict to ScheduleDispatchService (saveDispatch, adjustOrder)
- Use allEntries=true for DispatchService (DTO lacks competitionId)
- Create CacheConsistencyTest to verify cache eviction
- All 466 tests passing (added 2 cache consistency tests)

Cache Strategy:
- Query: @Cacheable with competitionId key
- Status/Arrange: @CacheEvict with competitionId key
- Dispatch: @CacheEvict with allEntries=true (no competitionId in DTO)

Data Consistency Guarantee:
- All mutation operations evict cache
- Test coverage for cache eviction behavior
- No stale data risk

Related to Phase 6 cache consistency requirements
This commit is contained in:
2026-01-18 02:49:44 +08:00
parent 9cc07fec9e
commit 12f77e3398
10 changed files with 62 additions and 0 deletions
@@ -11,6 +11,7 @@ import org.springblade.modules.martial.pojo.dto.*;
import org.springblade.modules.martial.pojo.vo.*;
import org.springblade.modules.martial.service.IScheduleDispatchService;
import org.springframework.stereotype.Service;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
@@ -94,6 +95,7 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService {
return result;
}
@CacheEvict(value = "scheduleResult", allEntries = true)
@Override
@Transactional(rollbackFor = Exception.class)
public boolean adjustOrder(org.springblade.modules.martial.pojo.dto.AdjustOrderDTO dto) {
@@ -159,6 +161,7 @@ public class ScheduleDispatchServiceImpl implements IScheduleDispatchService {
}
@Override
@CacheEvict(value = "scheduleResult", allEntries = true)
@Transactional(rollbackFor = Exception.class)
public boolean saveDispatch(org.springblade.modules.martial.pojo.dto.SaveDispatchDTO dto) {
if (dto.getAdjustments() == null || dto.getAdjustments().isEmpty()) {