mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Update README.md
This commit is contained in:
@@ -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<Integer, CharSequence> 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<Integer, CharSequence> 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<Integer, CharSequence> 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
|
||||
|
||||
Reference in New Issue
Block a user