Custom_In-Memory_Database 2.0.0

dotnet add package Custom_In-Memory_Database --version 2.0.0
                    
NuGet\Install-Package Custom_In-Memory_Database -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Custom_In-Memory_Database" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Custom_In-Memory_Database" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Custom_In-Memory_Database" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Custom_In-Memory_Database --version 2.0.0
                    
#r "nuget: Custom_In-Memory_Database, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Custom_In-Memory_Database@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Custom_In-Memory_Database&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Custom_In-Memory_Database&version=2.0.0
                    
Install as a Cake Tool

Custom In-Memory Database

About

This is a light-weight, in-memory database built as part of a research project at Cal Poly Pomona. It can especially be useful for testing purposes where you want isolated databases with ease of set up, and simulate real database functions.

Basic functionalities include all CRUD operations and aims to follow ACID architecture as closely as possible, inspired by PostgreSQL's implementations. It supports concurrency using Multi-Version Control Concurrency and async read write locks to simulate Read Commited isolation level. It can also perform type-checks, and save to disk on crash by default, and create a B-tree indexing to speed up query search.

Installation

On the command line interface:
dotnet add package Custom_In-Memory_Database

How to Setup

1. Dependency Injection

You can register the in-memory database service in your application by passing your service collection like this. DatabaseServiceRegistrar.AddInMemoryDBService(IServiceCollection service);
By default, it will register the necessary dependecies, FileManager and SearchManager, and the main Database class.

or

You can implement your own custom IFileManager and ISearchManager and either pass it along as parameters as below. Or if an instance is already registered in the DI container, it will be used. DatabaseServiceRegistrar.AddInMemoryDBService(IServiceCollection services,ISearchManager searchManager,IDiskManager diskManager);

2. Manually creating a Database Instance

Since the database class is public and available, you can directly create a database object and start using it:
var database = new Database(ISearchManager searchManager, IDiskManager diskManager);

See Reference Page for documentation

Limitations & Potential Plans

  • Atomicity is only supported for changing rows but not datatable structure.
  • Only includes simple add and retrieve, and no foreign keys or custom constraints.
  • Search parameters are simple and only allow one search condition.

Exception Handling

Most of the exceptions are still recoverable, meaning when an exception is thrown, the current transaction will abort, reverting to its previous working state. However, exceptions relating to File or locks, specifically LockNotReleasedException which is a custom exception type, will have persisting impacts, so you should probably restart it.

Nuget Package = https://www.nuget.org/packages/Custom_In-Memory_Database
Git Repo = https://github.com/Thet-Wai-123/In-Memory_Database

Acknowledgments

BTree library by CodeExMachina, licensed under GPLv3.0.

AsyncReaderWriterLock by .NEXT, licensed under MIT.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 45 11/5/2025
1.1.0 212 4/7/2025