Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In-process persistant key-value store for node.js

Tags:

node.js

I have a need to store some meta-data in a node.js application I am writing. Rather than come up with my own file format and managing that file, I would like to use an in-process persistant key-value store.

I was looking at mongodb but it seems that mongodb must always be run out-of-process (that is, you need to start a mongo server first, then connect to it in node.js.) I require that whatever store this is, that it exist entirely within the node.js process - or at least that any external processes are entirely managed transparently by the library, and kills them when the application closes the connection.

I don't care much about performance, but it would be nice to support asynchronous IO to the store to keep up with Node's whole async thing.

It would also be nice if the store supported indexes, as I will definitely be querying the data in a way where indexes would be helpful.

I'm pretty sure that 'sqlite' would work for me, except that I don't really see it as being nearly as convenient as a key-value store. Ideally I should be able to speak in JSON, not SQL. But sqlite will work if nothing better exists.

Thanks!

like image 274
eblume Avatar asked May 02 '12 08:05

eblume


4 Answers

Try nStore.
https://github.com/creationix/nstore

It's in process key-value store. Simple to use as well.

like image 185
Mahes Avatar answered Nov 01 '22 20:11

Mahes


Take a look to https://github.com/sergeyksv/tingodb. It is closely compatible to MongoDB API so you can upgrade to MongoDB when you'll need it.

like image 34
Sergey Korotkov Avatar answered Nov 01 '22 20:11

Sergey Korotkov


You might be interested in using redis http://redis.io/

There is a popular helper library for node https://github.com/mranney/node_redis

Then you can do this:

var redis = require("redis");
var client = redis.createClient();

client.set("foo_rand000000000000", "OK");
like image 37
250R Avatar answered Nov 01 '22 21:11

250R


I think you might be interested in final-db.

FinalDB uses file system to store it's data. It's not key-value store but document-based nosql solution. It supports indexes (maps) - you can specify map functions on each collection and of course it's an in process solution.

like image 36
Szymon Wygnański Avatar answered Nov 01 '22 20:11

Szymon Wygnański