3 ms·
The post dismisses UUIDs because their default formatting uses hyphens and hex encoding (base16), but as other comments mention you can get UUIDs to be much sho
by jmillikin 5y ago
The post dismisses UUIDs because their default formatting uses hyphens and hex encoding (base16), but as other comments mention you can get UUIDs to be much shorter by encoding them in a different base. If you want to guarantee URL-safety and selection via double-click, use base62 (26 lower-case, 26 upper-case, 10 digits).
uuid : c5831108-6f95-442a-b2b0-3c62dc0abdd1
base62: 60hNvkHrZykznfLaESuDBp
This format also lets you attach a prefix with '_' so you can keep track of the semantic type of each ID. This pattern is widely used by the Stripe API, and I've grown quite fond of it (so much easier to grep).
url: api.planetscale.com/v1/deploy-requests/deploy_60hNvkHrZykznfLaESuDBp
Additionally, within an in-memory value or a database, you probably want to store the decoded form of any ID. The value "deploy_60hNvkHrZykznfLaESuDBp" is 29 bytes long, but could be represented by `type DeployID byte[16]` for ~50% space savings and stronger type validation.