I fought a bit with HiLoIdGenerator, which comes with NoRM ( http://normproject.org/ ); I want to use it to create a unique identifier that I can use as SLUG for my blog posts. I am currently using ObjectId to uniquely identify a document in MongoDB, but since it is GUID-like and it does not look very good in the URL, I would rather have something like www.myblog.com/posts/1243 and therefore I decided to use HiLoIdGenerator.
I would like to generate my client-side HiLo identifier, and I read the staart harris blog http://red-badger.com/Blog/post/A-simple-IRepository3cT3e-implementation-for-MongoDB-and-NoRM.aspx , which NoRM new The HiLo Id generator also allows this by allocating an integer to the client session that can be used with impunity (other clients will use a different range), but when I opened HiLoIdGenerator, he said that the class is HiLoIdGenerator, which generates a new identification value using HILO algorithm. Only one instance of this class should be used in your project.
I really have three questions:
1) if I had multiple instances of HiLoIdGenerator in my application (for example, I had an instance in my service class that called GenerateId for each new document), I could actually guarantee that my entire identifier will be unique, given that Does the code for the HiLoIdGenerator class say that there should be only one instance of this class in the application?
2) the HiLoIdGenerator constructor takes a capacity argument, and I would like to know what it does, I passed 0, and all the generated identifiers were the same, then I passed one new HiLoIdGenerator (1), with which the Eid started from 1 and was increased by 1 ; I really donβt understand what it is doing, but I assume that it has something to do with a number of potential values ββthat the generator generates, but I'm not sure, and I would like to be. Can anyone explain this argument?
3) , HiLo, Hi/Lo?, , MongoDB , MongoDB, , , , .. , GUID, MongoDB, MongoDB ?