In my current design, I have HiLo setup to have a MaxLo
of 1000
. Is this being excessive? Could I reduce this number to something like 100
and still be ok?
public class HiLoConvention : IIdConvention
{
public void Apply(IIdentityInstance instance)
{
开发者_如何转开发 instance.GeneratedBy.HiLo("1000");
}
}
The HiLo value controls how "fast" you'll burn through the range of the numeric type you've selected for the Id. Anytime a new NHibernate configuration is loaded, the HiLo range of new Ids is initialized and it is discarded when the application is disposed. If your application has low activity and you want a "slow" burn rate pick something like 10 because your more likely to consume all Ids for a given application load/dispose cycle.
Remember, if NHibernate runs out of Ids, it just fetches another set. If your application gets slammed pretty regularly, then setting it at 1,000 may make more sense to reduce database calls. It a trial & error thing.
精彩评论