crypto.randomUUIDv7([options])
options<Object>disableEntropyCache<boolean> 默认情况下,为了提高性能,Node.js 会生成并缓存足够的随机数据以生成最多 128 个随机 UUID。要生成不使用缓存的 UUID,请将disableEntropyCache设置为true。默认值:false。
- 返回:<string>
生成一个随机的 RFC 9562 版本 7 UUID。UUID 的最高 48 位包含毫秒精度的 Unix 时间戳,其余字段由密码学安全的随机位组成,使其适合作为具有基于时间排序的数据库键使用。嵌入的时间戳依赖于非单调时钟,不能保证严格递增。
🌐 Generates a random RFC 9562 version 7 UUID. The UUID contains a millisecond precision Unix timestamp in the most significant 48 bits, followed by cryptographically secure random bits for the remaining fields, making it suitable for use as a database key with time-based sorting. The embedded timestamp relies on a non-monotonic clock and is not guaranteed to be strictly increasing.