通过序列动态数字
业务需要不同的数字范围,具体取决于他们要添加的数字类型。我总是会事先获得数字范围。
numberPool
ID | 名称 | range_start | range_end | sequence_name |
---|---|---|---|---|
1 | 项目 | 0 | 1000 | seq_items |
2 | 文档 | 500 | 1500 | seq_document |
3 | 项目 | 1001 | 3000 | SEQ_ITEMS2 |
4 | 项目 | 10000 | 11000 | SEQ_ITEMS3 |
NUMBERTABL
| | |
---|---|---|
| | |
| | |
| | |
| | FOOS |
项目 | 5000 | bar |
Document | 500 | Bar |
我想使用身份或序列来规避碰撞。我可以设置启动值和最大值,但是如果耗尽的话,我必须做出反应。
通过一个程序,我可以捕获“达到其最小值或最大值”。如果我剩下一个,请使用其他序列。有没有更好的方法来避免比赛状况并且仍然具有动态数字范围?
Business wants different numberranges depending which type of number they want to add. I get the Numberranges always beforehand.
NumberPool
id | name | range_start | range_end | sequence_name |
---|---|---|---|---|
1 | item | 0 | 1000 | seq_items |
2 | document | 500 | 1500 | seq_document |
3 | item | 1001 | 3000 | seq_items2 |
4 | item | 10000 | 11000 | seq_items3 |
NumberTable
Number_Type | number | more_metadata |
---|---|---|
item | 1 | foo |
item | 2 | bar |
item | ... | bar[numbers to 3 to 999] |
item | 1000 | foos |
item | 5000 | bar |
document | 500 | bar |
I wanted to use identity or sequences to circumvent collisions. I can set start values and max values but I have to react if they are exhausted.
With a procedure I could catch "has reached its minimum or maximum value." and use a different sequence if I have one remaining. Is there a better way to avoid race conditions and still have dynamic number ranges?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论