Cat.Util/Cat.IdGenerator/IdGeneratorHelper.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cat.Util;
using Cat.Util.Extension;
namespace Cat.IdGenerator
{
/// <summary>
/// 生成数据库主键Id
/// </summary>
public class IdGeneratorHelper2
{
private int SnowFlakeWorkerId = GlobalContext.SystemConfig.SnowFlakeWorkerId;
private Snowflake snowflake;
private static readonly IdGeneratorHelper2 instance = new IdGeneratorHelper2();
private IdGeneratorHelper2()
{
snowflake = new Snowflake(SnowFlakeWorkerId, 0, 0);
}
public static IdGeneratorHelper2 Instance
{
get
{
return instance;
}
}
public long GetId()
{
return snowflake.NextId();
}
}
public class IdGeneratorHelper
{
private IdGenerator idGenerator;
private static readonly IdGeneratorHelper instance = new IdGeneratorHelper();
private IdGeneratorHelper()
{
IdGeneratorOptions options = new IdGeneratorOptions()
{
WorkerId = 1
};
idGenerator = new IdGenerator(options);
}
public static IdGeneratorHelper Instance
{
get
{
return instance;
}
}
public long GetId()
{
后面还有 5 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。