如题?
https://github.com/broofa/node-uuid ?
@skipify 看起来太长了,有其他的选择吗
我想问为什么要自己去生成呢,为什么不用数据库的自增呢,这是出于安全考虑吗
@snowdream 太长?不是很理解,你其实要的是随机的类md5,但是可以指定长度?
场景是什么?
@alsotang 作为用户id,组id
我现在用passport.js方案,想在用户表中插入uid,gid字段
有个叫 shortid 的模块, 特点是短
感谢以上答复,准备使用以下模块》 https://github.com/mariodu/mongoose-id-autoinc
function guidGenerator() { var S4 = function() { return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1); }; return (S4() + S4() + S4() + S4() + S4() + S4() + S4() + S4()); }
https://github.com/vczero/OurTimes/blob/master/server/util/guid.js /**
module.exports = { create: function() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }).toUpperCase(); } };
感谢.选择了递增整数来做uid。
Redis 键值对里想做确保唯一性,用UUID,还是用Redis里面用 incr 叠加生成个ID ?
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
https://github.com/broofa/node-uuid ?
@skipify 看起来太长了,有其他的选择吗
我想问为什么要自己去生成呢,为什么不用数据库的自增呢,这是出于安全考虑吗
@snowdream 太长?不是很理解,你其实要的是随机的类md5,但是可以指定长度?
场景是什么?
@alsotang 作为用户id,组id
我现在用passport.js方案,想在用户表中插入uid,gid字段
有个叫 shortid 的模块, 特点是短
感谢以上答复,准备使用以下模块》 https://github.com/mariodu/mongoose-id-autoinc
https://github.com/vczero/OurTimes/blob/master/server/util/guid.js /**
感谢.选择了递增整数来做uid。
Redis 键值对里想做确保唯一性,用UUID,还是用Redis里面用 incr 叠加生成个ID ?