timepast
V2EX  ›  问与答

数据库的主键使用压缩后的 UUID (如:MFcAi8aAVvrVmYcPH5SjGR)

  •  
  •   timepast · Aug 8, 2014 · 4211 views
    This topic created in 4470 days ago, the information mentioned may be changed or developed.
    现在想设计成rest 风格的数字url 如:http://www.xxx.com/xxx/383958021/

    有什么好的解决思路呢 ?
    5 replies  •  2014-08-08 15:58:47 +08:00
    wingoo
    wingoo
    Aug 8, 2014
    1
    简单点的就每个char转换为2位数字,但生成后太长了
    nybux
    nybux
    Aug 8, 2014
    2
    uuid在系统内部是16个字节,你压缩后更长了
    ritksm
    ritksm
    Aug 8, 2014
    3
    维护一个map表不就行了么
    timepast
    timepast
    OP
    Aug 8, 2014
    4
    @wingoo 是啊
    @nybux Base58 压缩 36位 => 22位
    @ritksm 这样会多一次数据库的操作,看来只能这样了
    ipconfiger
    ipconfiger
    Aug 8, 2014
    5
    UUID只长不短,还是自增ID压缩好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1428 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 18:45 · PVG 02:45 · LAX 10:45 · JFK 13:45
    ♥ Do have faith in what you're doing.