Giter VIP home page Giter VIP logo

Comments (4)

ChinaLym avatar ChinaLym commented on July 24, 2024 3
* 1解决时钟回拨,时钟回拨后不可发号,必须要等到时钟追赶到回拨前的时间点。
  如果时钟回拨了重启可立马发号,不会重复(重启重新分配的workerID)。

* 2不需要手动配置machineId,通过db table auto increment发号。直到workerID=2^n 用完为止,发号器剧终!

我在犹豫几百万次的重启次数够用了吗,真的要在数据库里面插入几百万次吗,而且这些记录基本没有什么其他用处的

百万次重启次数通常足够,可以根据自己的适用场景设计清理策略,清理不需要的workId,如 workId自增数到达 10w 的倍数触发异步清理之前的数据,其实这个问题是由于没有回收机制导致的,也可以每小时向 mysql 中更新自己workId 所在的记录,每天清理更新时间 < 当前时间 - 24 小时的
上面仅仅是举例,如果发现默认设计不能很好的应对自己的业务场景,推荐考虑根据自身的场景量体裁衣。

from uid-generator.

zer0Black avatar zer0Black commented on July 24, 2024 1

该方案和雪花ID的最大区别,我认为就是解决了时间回拨问题。

from uid-generator.

kangwen avatar kangwen commented on July 24, 2024 1
  • 1解决时钟回拨,时钟回拨后不可发号,必须要等到时钟追赶到回拨前的时间点。
    如果时钟回拨了重启可立马发号,不会重复(重启重新分配的workerID)。
  • 2不需要手动配置machineId,通过db table auto increment发号。直到workerID=2^n 用完为止,发号器剧终!

from uid-generator.

honwhy avatar honwhy commented on July 24, 2024
* 1解决时钟回拨,时钟回拨后不可发号,必须要等到时钟追赶到回拨前的时间点。
  如果时钟回拨了重启可立马发号,不会重复(重启重新分配的workerID)。

* 2不需要手动配置machineId,通过db table auto increment发号。直到workerID=2^n 用完为止,发号器剧终!

我在犹豫几百万次的重启次数够用了吗,真的要在数据库里面插入几百万次吗,而且这些记录基本没有什么其他用处的

from uid-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.