Skip to content

Instantly share code, notes, and snippets.

@stefanotroia
Created December 11, 2019 07:32
Show Gist options
  • Save stefanotroia/5f41931d71ad3c483c52f2557589c5f9 to your computer and use it in GitHub Desktop.
Save stefanotroia/5f41931d71ad3c483c52f2557589c5f9 to your computer and use it in GitHub Desktop.
HazelCast service
@Service
@Slf4j
public class HazelcastService {
@Getter
private HazelcastInstance hzInstance;
@PostConstruct
private void init() {
// Running Hazelcast
hzInstance = Hazelcast.newHazelcastInstance();
}
@Bean
public Config hazelCastConfig() {
//config cache setup
Config config = new Config();
config.setInstanceName("EXAMPLE-CACHE");
MapConfig ourCache = new MapConfig();
ourCache.setTimeToLiveSeconds(1000);
ourCache.setEvictionPolicy(EvictionPolicy.LFU);
config.getMapConfigs().put("OUR_CACHE", ourCache);
return config;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment