InMemoryDocumentStore<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.DocumentStores
High-performance in-memory vector document store optimized for rapid prototyping and small-to-medium datasets.
Inheritance: DocumentStoreBase<T> → InMemoryDocumentStore<T>
For Beginners
An in-memory store keeps all your data in RAM (like variables in your program).
Think of it like a super-fast notebook that lives in your computer’s memory:
- Lightning-fast access (microseconds vs milliseconds)
- Zero configuration - just create and use
- Perfect for prototyping and testing
- Data is lost when the program stops
Best used for:
- Development and testing
- Session-based temporary data
- Caching frequently accessed vectors
- Small to medium datasets (< 100K documents)
Key characteristics:
- O(log n) similarity search using HNSW approximate nearest neighbor indexing
- Thread-safe concurrent access
- Low memory overhead with efficient storage
- Simple serialization/deserialization support
How It Works
This implementation provides a pure in-memory vector store using .NET’s high-performance collections, offering extremely fast vector similarity search with minimal configuration. Ideal for development, testing, caching layers, and applications with datasets that fit comfortably in RAM.
Constructors
| Constructor | Summary |
|---|---|
InMemoryDocumentStore(int vectorDimension, string databasePath, string tableName, int hnswMaxConnections, int hnswEfConstruction, int hnswEfSearch) |
Initializes a new instance of the InMemoryDocumentStore class. |
Properties
| Property | Summary |
|---|---|
int DocumentCount { get; } |
Gets the number of documents currently stored in the in-memory store. |
int VectorDimension { get; } |
Gets the dimensionality of vectors stored in this database. |
Methods
| Method | Summary |
|---|---|
void Clear() |
Removes all documents from the database and resets the vector dimension. |