In our multi module project, we have different cache present in different modules. And we fill all these caches on server startup in @PostConstruct. Now some cache depends on some other cache which may present in different modules. So it requires that some cache should be filled before the caches that depends on that cache. 1. How we can do this in Spring? Any design pattern I can leverage? 2. If a cache gets updated how we can propogate this updated change to those caches that depends on updated cache in real time?
module 1---
Cachce1
module 2--
Cache2
module 3--
Cache3
class Cache1 {
private ConcurrentMap<> cache;
@PostConstruct() {
cache = filleCache();
}
}
class Cache2 {
@Autowired
private Cache1 cache1;
private ConcurrentMap<> cache;
@PostConstruct() {
cache = cache1;
}
}
class Cache3 {
@Autowired
private Cache2 cache2;
private ConcurrentMap<> cache;
@PostConstruct() {
cache = cache2;
}
}