I once saw a joke on the Internet that saidUse Blazor+LiteDB to draw prototypes of invincible existenceRoughly speaking, it means that the prototype drawing is good, the function is also realized, and then the development efficiency and speed are also very fast.
LiteDB database
LiteDB is a small, fast, and lightweight NoSQL embedded database.
Official Website:The hyperlink login is visible. GitHub address:The hyperlink login is visible. LiteDB.Studio Visual GUI Tools:The hyperlink login is visible.
- Serverless NoSQL document storage
- Simple API similar to MongoDB
- 100% C# code, supports .NET 3.5 / .NET 4.0 / NETStandard 1.3 / NETStandard 2.0, single DLL (less than 300 kb)
- Support thread and process security
- Support for documentation/action-level ACID
- Support for data restoration after write failure (log mode)
- Data file encryption can be done using DES (AES) encryption algorithms
- You can use the feature or fluent mapping API to map your POCO class to BsonDocument
- Stores file and streaming data (MongoDB-like GridFS)
- Single-data file storage (similar to SQLite)
- Support for fast search based on document field indexes (up to 16 indexes per collection)
- Support for LINQ queries
- Shell Command Line - Try this online version
- Quite fast - here is the comparison with SQLite
- Open source and free for everyone - including commercial applications
- Can be installed from NuGet: Install-Package LiteDB
LiteDB vs. SQLite
Both are actually small databases, and neither needs to install a separate database service, and the database is just a separate file; It supports cross-platform and can be used on Windows, Linux, and mobile; LiteDB is a non-relational database, and SQLite is a relational database Performance comparison:The hyperlink login is visible.
.NET 7 uses LiteDB databases
First, create a new .NET 7 project and install the LiteDB database using the nuget command, the command is as follows:
Create a demo database and try to insert 100000 pieces of data with the following code:
Inserting 100,000 pieces of data, it feels like the whole program took 2 seconds.The disk size is 30.5 MBcan be queried using the LiteDB.Studio tool, as shown in the following image:
About database connection strings:The hyperlink login is visible., for example:
LiteDB offers 2 types of connections:DirectandShared. This affects how the engine opens data files.
Direct: The engine will open the data file in exclusive mode and keep it open until Dispose(). Another process cannot open the data file.This is the recommended mode and the default modeBecause it is faster and cacheable.
Shared: The engine closes the data file after each operation. The lock is made using Mutex. This is more expensive, but you can open the same file from multiple processes.
Trying to perform a query operation is also very fast, as follows:
LiteDB stores files
LiteDB also supports storage file operations, that is, you can store images, documents, tables, and other content of websites directly into the LiteDB database, the code is as follows:
(End)
|