Client side id generation strategy for REST web service

眉间皱痕 提交于 2019-12-05 10:34:35

There is a reason why highly distributed system (like , , etc.) use long UUIDs/hashes while centralized relational databases (or for that matter) can simply use ints. There is no easy way of creating short ids on the client-side in a distributed fashion. Either the server handles them or you must live with wasteful ids. Typically they contain encoded timestamp, client/computer id, hashed content, etc.

That's why REST services typically use

POST /notes

for non-idempotent save and then use the output of Location: header in response:

Location: /notes/42
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!