Comments (1)
非常感谢。的确是有重复了。
原因比较微妙,最开始设计时,在redis上做计数的key是带有毫秒的,第一版是改redis的代码来增加了一个获取时间的command。
后来,redis内置了time命令之后,改为利用redis的time命令。但是redis的lua脚本里限制了,执行time命令之后不能再执行write操作。所以把做计数的key里去掉了毫秒数。
但是这个实际上是有问题的。简而言之,获取到time这个时间点和计数key失效并不是绝对的一致的,导致后面生成的ID可能会重复。
新改的方案,改回了原始的设计,在计数key里加入了毫秒,这样子则保证了不会在同一个毫秒里出现重复的ID。
因为使用到了redis.replicate_commands()
,所以要求要用3.2版本以上的redis server。
from redis-id-generator.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from redis-id-generator.