Skip to content

Instantly share code, notes, and snippets.

@scheler
Last active July 22, 2018 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scheler/b2fd24c10652b8ec3cb5a0faa5c38e46 to your computer and use it in GitHub Desktop.
Save scheler/b2fd24c10652b8ec3cb5a0faa5c38e46 to your computer and use it in GitHub Desktop.
hazelcast map listener example python
import hazelcast, logging
config = hazelcast.ClientConfig()
# Hazelcast.Address is the hostname or IP address, e.g. 'localhost:5701'
config.network_config.addresses.append('localhost5701')
# basic logging setup to see client logs
logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)
client = hazelcast.HazelcastClient(config)
my_map = client.get_map("map-name").blocking()
print my_map
future = my_map.put("key", "async_val")
def item_added(event):
print("item_added", event)
def item_removed(event):
print("item_removed", event)
def item_updated(event):
print("item_updated", event)
my_map.add_entry_listener(include_value=True, added_func=item_added, removed_func=item_removed, updated_func=item_updated)
future = my_map.put("key1", "async_val")
future = my_map.put("key2", "async_val")
future = my_map.put("key", "new val")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment