- Hazelcast Go Client
- Features
- Installing the Client
- Using the Client
- Serialization Considerations
- Development
- Testing
- Mail Group
- License
- Copyright
Go client implementation for Hazelcast, the open source in-memory data grid.
Go client is implemented using the Hazelcast Open Binary Client Protocol.
This client works with Hazelcast 3.6 and higher.
Hazelcast is a clustering and highly scalable data distribution platform. With its various distributed data structures, distributed caching capabilities, elastic nature and more importantly with so many happy users, Hazelcast is a feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.
NOTE: This project is currently in active development.
Hazelcast Go client supports the following data structures and features:
- Map (including entry processors and
PartitionAware
keys) and MultiMap - Smart Client
- Hazelcast Native Serialization
- Distributed Object Listener
- Lifecycle Service
Following command installs Hazelcast Go client:
go get github.com/hazelcast/hazelcast-go-client
Following code snippet illustrates a simple usage of Map in Hazelcast Go Client.
config := hazelcast.NewHazelcastConfig()
config.ClientNetworkConfig().AddAddress("127.0.0.1:5701")
client, err := hazelcast.NewHazelcastClientWithConfig(config)
if err != nil {
fmt.Println(err)
return
}
mp, _ := client.GetMap("simpleExample")
mp.Put("key1", "value1")
mp.Put("key2", "value2")
result1, _ := mp.Get("key1")
fmt.Println("key1 has the value of ", result1)
result2, _ := mp.Get("key2")
fmt.Println("key2 has the value of ", result2)
mp.Clear()
client.Shutdown()
Please see Hazelcast Go code samples for more examples.
You can also refer to Hazelcast Go API Documentation.
Hazelcast needs to serialize objects in order to be able to keep them in the server memory. For primitive types, it uses Hazelcast native serialization. For other complex types (e.g. Go objects), it uses Gob serialization.
For example, when you try to query your data using predicates, this querying is handled on the server side so Hazelcast does not have to bring all data to the client but only the relevant entries. Otherwise, there would be a lot of unneccessary data traffic between the client and the server and the performance would severely drop. Because predicates run on the server side, the server should be able to reason about your objects. That is why you need to implement serialization on the server side.
The same applies to MapStore. The server should be able to deserialize your objects in order to store them in MapStore.
Regarding arrays in a serializable object, you can use methods like WriteInt32Array
if the array is of a primitive type.
If you have nested objects, these nested objects also need to be serializable. Register the serializers for nested objects and the method WriteObject
will not have any problem with finding a suitable serializer for and writing/reading the nested object.
Follow the below steps to build and install Hazelcast Go client from its source:
- Clone the GitHub repository https://github.com/hazelcast/hazelcast-go-client.git.
- Run
sh build.sh
.
Following command starts the tests:
Run sh localTest.sh
Please join the mail group if you are interested in using or developing Hazelcast.
http://groups.google.com/group/hazelcast
Hazelcast is available under the Apache 2 License. Please see the Licensing appendix for more information.
Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
Visit www.hazelcast.com for more information.