The growing pain of caches in microservices

Working with cache is supposed to make our lives better. But what if implementing it creates more problems ?

It all starts with an innocent idea…

Why do we necessarily need caches ?

Considerations when building cache mechanism

Cache Types

A simple illustration to describe differences between in-memory and external caches.

Data to cache and its size

Availability and Accuracy

Implementations

Develop

Combining both in-memory and external cache produces a great result !
public class ChannelConfigurationCacheImpl {    private Map<String, String> channelConfigurationMap = new HashMap<>();

ChannelBrokerService channelBrokerService;

public String getChannelConfiguration(String channelId) {
String result = channelConfigurationMap.get(channelId); if (result == null) {
result = getFromCacheBroker(channelId);
}
return result;
}
public String getFromCacheBroker(String channelId) {
return cacheBrokerService.getChannelConfiguration(channelId);
}
public void setChannelBrokerService(ChannelBrokerService channelBrokerService) {
this.channelBrokerService = channelBrokerService;
}
}

Maintain

Document

What comes next ?

--

--

Software Developer @ DANA

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store