Last active
July 22, 2018 00:37
-
-
Save scheler/b2fd24c10652b8ec3cb5a0faa5c38e46 to your computer and use it in GitHub Desktop.
hazelcast map listener example python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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