Right now we are contacting the DB twice whenever we create a new Object
Get Object ID
Create
It seems to make more sense to contact the DB only once to create a new object. Here are two approaches:
Randomly generate
Pros:
Easy
makes it easy to send object creation messages - the objects can wait in a go channel while they are being
Cons:
IDs have to be much longer. Makes sets and objects take take more memory
In the event that we do generate a duplicate ID there is no convenient way to notify the sender
Have Redis Generate IDs
Pros:
We have confidence that our object will be created with a unique ID
Cons
Aether needs to wait for redis's permission to create an object. This is currently what we are doing.
Goals
I would like a solution where I don't have to manually add an ID to an object before calling "create" sending it to redis.
I would like a solution where new objects can be copied and sent to redis via a go channel. For this to work we will need to either
Contact DB twice (as we are currently doing)
Generate Random ID (Probably best choice
Wait on Redis to create the object. Redis can generate the ID and insert it into the documents. This would be pretty annoying to program in a redis script. Otherwise we have to send data to redis, wait for it to come back.
Right now we are contacting the DB twice whenever we create a new Object
It seems to make more sense to contact the DB only once to create a new object. Here are two approaches:
Randomly generate
Have Redis Generate IDs
Goals
I would like a solution where I don't have to manually add an ID to an object before calling "create" sending it to redis.
I would like a solution where new objects can be copied and sent to redis via a go channel. For this to work we will need to either