From c8f9c31dbdd9ed45812be7ce7ba1c3ae9fcedb2c Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Tue, 7 Oct 2014 16:37:24 +0100 Subject: [PATCH] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 5e1bb2bba..b94458266 100644 --- a/README.md +++ b/README.md @@ -596,6 +596,45 @@ will run out of space between 1 and 2 million entries. You should set the .entries(..) and .entrySize(..) to those you require. +# Example :Simple Hello World + +This simple chronicle map, works just like ConcurrentHashMap but stores its data off-heap. If you want to use Chronicle Map to share data between java process you should look at the next exampl + +``` java +Map map = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(); + +map.put(1, "hello world"); +System.out.println(map.get(1)); + +``` + +# Example : Sharing the map on two ( or more ) processes on the same machine + +Lets assume that we had two server, lets call them server1 and server2, if we wished to share a map +between them, this is how we could set it up + +``` java + +// --- RUN ON ONE JAVA PROCESS ( BUT ON THE SAME SERVER ) +{ + File file = new File("a-new-file-on-your-sever"); + Map map1 = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(file); // this has to be the same file as used by map 2 + map1.put(1, "hello world"); +} + +// --- RUN ON THE OTHER JAVA PROCESS ( BUT ON THE SAME SERVER ) +{ + File file = new File("a-new-file-on-your-sever"); // this has to be the same file as used by map 1 + Map map1 = ChronicleMapBuilder.of(Integer.class, + CharSequence.class).create(file); + + System.out.println(map1.get(1)); +} +``` + + # Example : Replicating data between process on different servers via TCP Lets assume that we had two server, lets call them server1 and server2, if we wished to share a map