Skip to content

Repository files navigation

StringDB

StringDB

Build StatusTest StatusNuget VersionNuget Downloads

Install-Package StringDB

Introduction

StringDB is a key/value pair store with a friendly API to use as little RAM and space as possible.

Verify the claims for yourself:

Api

Enumerate over a database and it's values, the fastest, by enumerating over it optimally

usingvardb=newDatabaseBuilder().UseIODatabase(StringDBVersion.Latest,"database.db",outvaroptimalTokenSource).WithBuffer(1000).WithTranform(StringTransformation.Default,StringTransformation.Default);foreach(var(key,value)indb.EnumerateOptimally(optimalTokenSource)){// do something with the key and value}

Use fluent extensions to create a database:

usingIDatabase<string,string>db=newDatabaseBuilder().UseIODatabase(StringDBVersion.Latest,"database.db").WithBuffer(1000).WithTransform(StringTransformation.Default,StringTransformation.Default);usingIDatabase<int,string>memDb=newDatabaseBuilder().UseMemoryDatabase<int,string>();

Use the IDatabase interface to interface with databases

voidInsertGreeting(IDatabase<string,string>database,stringuser){database.Insert(user,$"Greetings, {user}!");}

And inherit BaseDatabase to create your own IDatabases with minimal effort

publicclassTestDatabase:BaseDatabase<int,string>{privateclassLazyValue:ILazyLoader<string>{privatereadonlystring_value;publicLazyValue(intvalue)=>_value=value.ToString();publicstringLoad()=>_value;publicvoidDispose(){}}publicoverridevoidDispose(){}protectedoverridevoidInsertRange(KeyValuePair<int,string>[]items){foreach(variteminitems){Console.WriteLine($"{item.Key}: {item.Value}");}}protectedoverrideIEnumerable<KeyValuePair<int,ILazyLoader<string>>>Evaluate(){for(vari=0;i<int.MaxValue){yieldreturn KeyValuePair.Create(i,newLazyValue(i));}}}

Tiny icon_tiny

StringDB is tiny. Use tiny amounts of RAM, and tiny amounts of space.

Chart

InsertsSize (in KB, 1000 bytes)Absolute Minimum Size PossibleStringDB Overhead Percentage
11.172 KB1.152 KB1.706485%
5058.208 KB57.6 KB1.04453%
100116.408 KB115.2 KB1.037729%

This chart shows the size of a StringDB file after multiple single inserts. Every key is 128 bytes long, and every value is 1024 bytes long. By doing single inserts, file size is dramatically affected due to the additional overhead for the index chain.

Chart

Elements in Insert RangeSize (in KB, 1000 bytes)Absolute Minimum Size PossibleStringDB Overhead Percentage
11.172 KB1.152 KB1.706485%
5057.963 KB57.6 KB0.626262%
100115.913 KB115.2 KB0.615117%

This chart shows the size of a StringDB file after a single insert range with the amount of items specified.

Addons

Official addon support will be maintained for these libraries.

Issues welcomed!

Don't be afraid to make an issue about anything and everything!

  • Is there something weird with how databases are created? Submit an issue!
  • Is there something that you wish you could do but can't? Submit an issue!
  • Is this library not suitable for your purposes? Submit an isssue!
  • Want it to do something? Submit an issue!

It's an honour to have you use this library, and feedback is needed to make this the greatest it can be.

Need immediate assistence? Join the discord!

About

StringDB is a modular, key/value pair archival DB designed to consume *tiny* amounts of ram & produce *tiny* databases.

Topics

Resources

Stars

71 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages