Lightweight, persistent, thread-safe, disk-based queue, stack, dictionary, and list, written in C#
$ dotnet add package PersistentCollection![]()
Lightweight, persistent, thread-safe, disk-based collection classes written in C# for queue, stack, dictionary, and list. All classes leverage a file to enable persistence across instantiations of the object or restarts of the software.
IMPORTANT:
PersistentList, PersistentQueue, PersistentDictionary, and PersistentStackPersistentCollectionRefer to the Test project for a working example.
PersistentList implements the interface of System.Collections.Generic.List<T>.
using PersistentCollection;
PersistentList<string> myList = new PersistentList<string>("./list.idx");
myList.Add("foo");
myList.Add("bar");
string val = myList.Get(1);
myList.RemoveAt(1);
PersistentQueue mimics the behavior of System.Collections.Generic.Queue<T>.
using PersistentCollection;
PersistentQueue<string> myQueue = new PersistentQueue<string>("./queue.idx");
myQueue.Enqueue("foo");
myQueue.Enqueue("bar");
string val = myQueue.Dequeue(); // foo
PersistentStack mimics the behavior of System.Collections.Generic.Stack<T>.
using PersistentCollection;
PersistentStack<string> myStack = new PersistentStack<string>("./stack.idx");
myStack.Push("foo");
myStack.Push("bar");
string val = myStack.Pop(); // bar
PersistentDictionary implements the interface of System.Collections.Generic.IDictionary<TKey, TValue>.
using PersistentCollection;
PersistentDictionary<string, string> myDict = new PersistentDictionary<string, string>("./dict.idx");
myDict.Add("name", "Joel");
myDict.Add("hobbies", "code");
string val = myDict["name"]; // Joel
Refer to CHANGELOG.md for version history.