SkillAgentSearch skills...

PersistentCollection

Lightweight, persistent, thread-safe, disk-based collections written in C#, including dictionary, list, queue, and stack.

Install / Use

/learn @jchristn/PersistentCollection
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

alt tag

PersistentCollection

NuGet Version NuGet

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:

  • To provide persistence, the internal data structure is persisted to disk in full any time a change is made
  • Thus, this library is NOT APPROPRIATE for large amounts of data or a large number of records
  • It is recommended that these classes be used sparingly, when record counts are less than 1000 and total size is less than 10MB

New in v2.0.x

  • Remove expiration
  • Migrate existing implementation to PersistentList, PersistentQueue, PersistentDictionary, and PersistentStack
  • Rename package to PersistentCollection

Getting Started

Refer to the Test project for a working example.

PersistentList

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

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

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

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

Version History

Refer to CHANGELOG.md for version history.

View on GitHub
GitHub Stars13
CategoryDevelopment
Updated6mo ago
Forks1

Languages

C#

Security Score

82/100

Audited on Sep 19, 2025

No findings