petersirka/nosql

Simultaneous acces

FlorianBruniaux opened this issue · 8 comments

Hello,

I'm considering using your nosql embedded solution but I was wondering if it allows simultaneous acces ? Even with a lock system for example...

For example :
ComputerA et ComputerB are both connected to the network.
nosql database file is store in a folder of the network (and so is accessible by both computers)

--> Is it possible that CompA reads database file while CompB is writing in ?

Thanks

Florian

Hi @FlorianBruniaux,
Yes. NoSQL embedded database contains mini lock mechanism.

https://github.com/petersirka/nosql/blob/master/index.js#L58

Thanks! :-)

Oh nice !

(To be Frank i'm comparing your solution vs NeDB and TingoDB)

Is there a mechanism to sync 2 dbfile ?

I mean for example :
you have db1.db and db1.copy.db
You make some changes on db1.copy.db

Can we compare these 2 files to detect differences ?

Sorry - but DB doesn't have mechanism to sync 2 or more db files.
Only option is to capture events and according events to sync data between databases. Do you understand?

PS: thank your for your mention about NeDB and TingoDB - I'll check it out.
Thanks!

Sorry but I don't really understand what you mean by "capturing events and according events to sync data between databases".
Do you mean something like record each db command (like "del line xxx") create a sequence of commands and play this sequence to each db to "simulate" sync?

Yes.

I thought about something like this. But i found it a bit complicated because for example:

if there is original.db
A copy to copy1.db
B copy to copy2.db

A makes some changes on copy1.db
B makes changes on copy2

Then we want to update original.db with both copy1 and copy2 ...

How can we deal with concurrency changes (for example modification of the same object)...?

Tricky nop?

This database was not created for complicated operations. You will need to find a solution for resolve your needs and this will not be easy. 100% synchronization will be a problem in the future.

Theoretically I could add this feature to future.
Thanks.

Yeah I know, it'll not be easy...

If I find a solution I'll tell you how to deal with this problem

Thanks for your answers

Florian