hmalphettes / redisdown

Redis backend for LevelUP
MIT License
75 stars 14 forks source link

Concurrent write question #6

Closed mike-zorn closed 10 years ago

mike-zorn commented 10 years ago

Has redisdown been tested with multiple node processes using levelUP to write to the same redis server?

hmalphettes commented 10 years ago

I have not tested it in that situation yet.

hmalphettes commented 10 years ago

@apechimp this scenario is one of the main motivation for developing redisdown.

I cannot see why it would not work. If it is not working please do report it. Improvements are also welcomed.

Redisdown is a thin layer on the top of redis: it gives you the same guarantees than redis, albeit fairly weak.

1- During a read redisdown does not make a snasphot of the data: what it reads is what is in the database each time it fetches a set of records. If some records are added, removed or modified while they are iterated on they will show up or not in the iterated values. This is weaker than leveldown but in-line with redis: Elements that were not constantly present in the collection during a full iteration, may be returned or not: it is undefined.

2- During a write there is no locking mechanism in place: the last write command for a given key that reaches the redis-server is the one that will overwrite everything else.

If it does not fit the bill one can either pick a different implementation (riak, postgres) or add some other layers to go through: a queue when writing, another abstraction like dat or pouchdb where all records are version-ed.

mike-zorn commented 10 years ago

Makes sense. I hadn't run into any issues; just wanted to make sure this was something redisDOWN was intended to do as that is essentially my use case.