Arcane
Arcane

Reputation: 117

Is Redis used to store auto-incrementing IDs for databases

I am planning on using Redis to generate and store autoincrementing IDs that I will use as primary key fields in MongoDB.

Is this a good idea given the resiliency and durability of Redis. I am worried that if Redis goes down, I might have to deal with duplicate key issues in MongoDB.

I'm planning on implementing Redis using the Append Only File option, and performing an fsync every time a new command is appended to the AOF. It will be slower but more durable.

I am planning on sharding MongoDB in the future and would like to have the IDs be sequential instead of of using Mongo's internal time based IDs.

Upvotes: 1

Views: 1163

Answers (2)

Arcane
Arcane

Reputation: 117

After doing some more research and watching the training videos on 10gen, I see that the approach to use sequential IDs is flawed, so I will not use Redis in this fashion.

Upvotes: 0

E.J. Brennan
E.J. Brennan

Reputation: 46859

Might work, but if that is your only use for redis, seems like a bunch of complexity for something that is already available right in mongodb:

http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/

Upvotes: 1

Related Questions