-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changing the way PostIDs are created #131
Milestone
Comments
Closed
I'm starting today afternoon with this |
RiccardoM
changed the title
Changing the wayt PostIDs are created
Changing the way PostIDs are created
Apr 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
Currently when creating a new
Post
, it'sID
field is generated sequentially by taking the last id and adding1
to it.While this surely works, it is just a very naive way of generating ids in a very determininistic way that might have some downsides as newer ids can be inferred.
A part from this, a serie of checks must be put in place in order to maintain the ordering of such ids, as I've also outlined inside #90.
Solution
In order to properly change this, I propose a new way of deterministically generating post IDs that cannot be infered and also will allow for some performance improvements:
This way we could also remove the current way of checking if a post collides with another one which is currently causing a lot of performance probles as we iterate over all the posts.
Using this ID system, instead, we could simply check if such key already exists inside the store and if it does, it means the post is duplicated.
The implementation could be done directly inside the
NewPost
method, generating the ID there instead of outside of it.Notes
When implementing this, a migration should also be implemented to transform
0.3.0
post ids into the new type by performing the appropriate convertion.The text was updated successfully, but these errors were encountered: