Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // on application instance start, init near cache Map
- const {Client, Config} = require('hazelcast-client')
- const nearCachedMapName = 'my-holy-fast-map'
- const cfg = new Config.NearCacheConfig()
- cfg.name = nearCachedMapName
- cfg.invalidateOnChange = true
- cfg.nearCacheConfigs[nearCachedMapName] = cfg
- const hazelcast = await Client.newHazelcastClient(cfg)
- const locations = hazelcast.getMap(nearCachedMapName)
- // on application instance start, fill map with locations once
- if (await locations.size() === 0) {
- (await LocationsService.findAll()).forEach(location => {
- locations.put(location._id, location)
- })
- }
- // on location change
- await locations.put(location._id, location)
- // on locations retrieval "GET /locations"
- await locations.values()
Add Comment
Please, Sign In to add comment