Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Looking for a simple standalone persistent dictionary implementation in C# [closed]

Tags:

For an open source project I am looking for a good, simple implementation of a Dictionary that is backed by a file. Meaning, if an application crashes or restarts the dictionary will keep its state. I would like it to update the underlying file every time the dictionary is touched. (Add a value or remove a value). A FileWatcher is not required but it could be useful.

class PersistentDictionary<T,V> : IDictionary<T,V> {     public PersistentDictionary(string filename)     {      }  } 

Requirements:

  • Open Source, with no dependency on native code (no sqlite)
  • Ideally a very short and simple implementation
  • When setting or clearing a value it should not re-write the entire underlying file, instead it should seek to the position in the file and update the value.

Similar Questions

  • Persistent Binary Tree / Hash table in .Net
  • Disk backed dictionary/cache for c#
  • PersistentDictionary<Key,Value>
like image 659
Sam Saffron Avatar asked Sep 19 '08 07:09

Sam Saffron


2 Answers

  • bplustreedotnet

    The bplusdotnet package is a library of cross compatible data structure implementations in C#, java, and Python which are useful for applications which need to store and retrieve persistent information. The bplusdotnet data structures make it easy to store string keys associated with values permanently.

  • ESENT Managed Interface

    Not 100% managed code but it's worth mentioning it as unmanaged library itself is already part of every windows XP/2003/Vista/7 box

    ESENT is an embeddable database storage engine (ISAM) which is part of Windows. It provides reliable, transacted, concurrent, high-performance data storage with row-level locking, write-ahead logging and snapshot isolation. This is a managed wrapper for the ESENT Win32 API.

  • Akavache

    *Akavache is an asynchronous, persistent key-value cache created for writing native desktop and mobile applications in C#. Think of it like memcached for desktop apps.

- The C5 Generic Collection Library

C5 provides functionality and data structures not provided by the standard .Net System.Collections.Generic namespace, such as persistent tree data structures, heap based priority queues, hash indexed array lists and linked lists, and events on collection changes.

like image 112
lubos hasko Avatar answered Sep 17 '22 15:09

lubos hasko


Let me analyze this:

  1. Retrieve information by key
  2. Persistant storage
  3. Do not want to write back the whole file when 1 value changes
  4. Should survive crashes

I think you want a database.

Edit: I think you are searching for the wrong thing. Search for a database that fits your requirements. And change some of your requirements, because I think it will be difficult to meet them all.

like image 30
GvS Avatar answered Sep 19 '22 15:09

GvS