I have service:
@Service
public class ErrMessageServiceImpl implements ErrMessageService {
private final ErrMessageRepository errMessageRepository;
public ErrMessageServiceImpl(ErrMessageRepository errMessageRepository) {
this.errMessageRepository = errMessageRepository;
}
@Override
@Cacheable("errorMessages")
public ErrMessage getOneByCode(int code) {
return errMessageRepository.getOneByCode(code);
}
}
I read that this default implementation work with ConcurrentHashMap
Initially, the project does not define any caching library so the abstraction works on simple ConcurrentHashMap-based caches. You can try out your favorite caching library as explained below. link
All work fine. But now I need refresh Cache
every 10 minutes. But I not understand how can I do it? I suspect I need use some provider and configure it - Caffeine
, Redis
and etc. Or I can configure default ConcurrentHashMap
and set refresh interval?