开发者

UUID namespace and name. How to retrieve it?

开发者 https://www.devze.com 2022-12-09 15:17 出处:网络
I have the following problem. I assign to an开发者_Python百科y object in my database a UUID. When I get a UUID from any source, to obtain the object I need to know what type of object is, so I can que

I have the following problem. I assign to an开发者_Python百科y object in my database a UUID. When I get a UUID from any source, to obtain the object I need to know what type of object is, so I can query the correct table in the database. As far as I understand, UUID version 5 supports namespacing, but I am not sure I clearly understand its meaning.

Is it possible to associate to a UUID information about the namespace it belongs, so to recover it later ?


Is it possible to associate to a UUID information about the namespace it belongs,

Yes, see this document.

so to recover it later

Maybe. The problem is that two different namespaces may map to the same hash value. To avoid this, you should manually number your names (instead of hashing them). Then put the number into the octets 0-3. That gives you a deterministic mapping between UUIDs and names.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号