Skip to main content


For a small project of mine, I needed a really simple DB (so simple, you can't call it a DB actually ;) ). The requirements were:

  • Fast lookup
  • Storage of raw byte streams for both key/data
  • Pure MSIL - otherwise, I would have used the BerkeleyDB
  • Checksumming for each entry to detect long-term corruption

I ended up with writing a very simple DB in C# ... the trickiest part was to get the paging right, as the pages get ref-counted just like everything else, but you do actually want to know when the last handle to them finishes and flush them to disk. The DB is ~16 kb large (Binary), allows storing/loading of entries (no update so far, delete does not compact) as long as the entries are smaller than the page size. All entries are hashed before storage, so data corruption can be detected. Moreover, the index and free page table can be recreated just from the storage file. I'm using it currently for a small mail storage system, where it works pretty fine and is really simple to use -- something which was crucial to me as I often need just one simple tool for something totally different and I hate spending hours just to fiddle around with some complex solution -- for example SQLite -- to write a simple wrapper around it for my own little needs (plus, most C# wrappers require the original binaries, which often run only on x86 but not on x64 as there are no binaries for that, let alone porting it to Mono ...).