How to use nodejs module to put data into map and keep it not duplicate and synchronous

1.4k views Asked by At

I need to read some data from a file and put some not duplicated keys into a map, to keep it synchron. Should I use hashtable or hashmap and sync block or nodejs module? Do you have any advice? Is there available concurrent hashmap module in nodejs ?

1

There are 1 answers

0
Hyo Byun On

Just use a javascript object.

var myObject = {};

//add Key/Value pair
myObject["myKey"] = "myValue"

//Look Up
myObject["myKey"]

You will not have to worry about this variable being concurrent or synchronized in node.js since it is single-threaded.