timepast
V2EX  ›  问与答

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

  •  
  •   timepast · Aug 8, 2014 · 3981 views
    This topic created in 4324 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
        1
    wingoo  
       Aug 8, 2014
    简单点的就每个char转换为2位数字,但生成后太长了
    nybux
        2
    nybux  
       Aug 8, 2014
    uuid在系统内部是16个字节,你压缩后更长了
    ritksm
        3
    ritksm  
       Aug 8, 2014
    维护一个map表不就行了么
    timepast
        4
    timepast  
    OP
       Aug 8, 2014
    @wingoo 是啊
    @nybux Base58 压缩 36位 => 22位
    @ritksm 这样会多一次数据库的操作,看来只能这样了
    ipconfiger
        5
    ipconfiger  
       Aug 8, 2014
    UUID只长不短,还是自增ID压缩好了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1141 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 23:10 · PVG 07:10 · LAX 16:10 · JFK 19:10
    ♥ Do have faith in what you're doing.