mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-13 06:24:35 +01:00
optimize db writes, should improve performance in high player server
This commit is contained in:
@@ -33,6 +33,18 @@ namespace Common.Database
|
||||
InitData(uid);
|
||||
return collection.AsQueryable().Where(x => x.OwnerUid == uid && ShowMapList.Contains(x.MapId)).ToList(); ;
|
||||
}
|
||||
|
||||
public static void SaveBulk(IEnumerable<OpenWorldScheme> openWorlds)
|
||||
{
|
||||
List<WriteModel<OpenWorldScheme>> ops = new();
|
||||
|
||||
foreach (OpenWorldScheme ow in openWorlds)
|
||||
{
|
||||
ops.Add(ow.SaveOp());
|
||||
}
|
||||
|
||||
collection.BulkWrite(ops);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
@@ -50,5 +62,10 @@ namespace Common.Database
|
||||
{
|
||||
OpenWorld.collection.ReplaceOne(Builders<OpenWorldScheme>.Filter.Eq(x => x.Id, Id), this);
|
||||
}
|
||||
|
||||
public WriteModel<OpenWorldScheme> SaveOp()
|
||||
{
|
||||
return new ReplaceOneModel<OpenWorldScheme>(Builders<OpenWorldScheme>.Filter.Eq(x => x.Id, Id), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user