Configuration Options for Vector Storage in AntSK: Disk, Memory, Qdrant, and Redis
AntSK configures vector storage through the KernelMemoryOption static class, supporting Disk, Memory, Qdrant, Redis, PostgreSQL, and Azure AI Search via Microsoft's Kernel Memory library.
AntSK is an open-source AI knowledge base application that leverages Microsoft's Kernel Memory to store and retrieve vector embeddings. The framework abstracts vector database selection through a simple configuration-based approach defined in src/AntSK.Domain/Options/KernelMemoryOption.cs, allowing developers to switch between local file storage, in-memory caches, or dedicated vector databases like Qdrant and Redis without changing application code.
How Vector Storage Configuration Works in AntSK
The vector storage system centers on three static properties in the KernelMemoryOption class:
public static string VectorDb { get; set; } // "Disk", "Memory", "Qdrant", "Redis", etc.
public static string ConnectionString { get; set; } // Provider-specific connection details
public static string TableNamePrefix { get; set; } // Used exclusively by PostgreSQL
These values are consumed by the WithMemoryDbByVectorDB method in src/AntSK.Domain/Domain/Service/KMService.cs (lines 37-79), which acts as a switch router. Based on the VectorDb value, this method invokes the appropriate extension method on the KernelMemoryBuilder to wire in the correct vector database implementation.
Supported Vector Storage Providers
Disk-Based Storage (SimpleVectorDb)
The Disk option persists vectors as binary files on the local file system using Kernel Memory's SimpleVectorDb.
| Configuration | Value |
|---|---|
VectorDb |
Disk |
ConnectionString |
Not required |
TableNamePrefix |
Not required |
Implementation Detail: In KMService.cs (lines 52-56), the builder configures:
memory.WithSimpleVectorDb(new SimpleVectorDbConfig {
StorageType = FileSystemTypes.Disk
});
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "Disk"
}
}
This mode is ideal for single-node deployments, development environments, or scenarios where external database infrastructure is unavailable.
In-Memory Storage (Volatile)
The Memory option stores all vectors in RAM using a volatile, non-persistent cache.
| Configuration | Value |
|---|---|
VectorDb |
Memory |
ConnectionString |
Not required |
TableNamePrefix |
Not required |
Implementation Detail: In KMService.cs (lines 60-64), the configuration uses:
memory.WithSimpleVectorDb(new SimpleVectorDbConfig {
StorageType = FileSystemTypes.Volatile
});
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "Memory"
}
}
Use this for unit testing, ephemeral workloads, or high-performance temporary caching where data loss on restart is acceptable.
Qdrant Vector Database
Qdrant is a dedicated vector database optimized for similarity search and AI applications.
| Configuration | Value |
|---|---|
VectorDb |
Qdrant |
ConnectionString |
`"{host} |
TableNamePrefix |
Not required |
Implementation Detail: In KMService.cs (lines 65-68), the connection string is parsed and passed to:
var qdrantConfig = ConnectionString.Split("|");
memory.WithQdrantMemoryDb(qdrantConfig[0], qdrantConfig[1]);
qdrantConfig[0]= Qdrant host URL (e.g.,http://localhost:6333)qdrantConfig[1]= API key (optional; use empty string if authentication is disabled)
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "Qdrant",
"ConnectionString": "http://localhost:6333|my-qdrant-api-key"
}
}
Qdrant is recommended for production deployments requiring horizontal scalability and high-throughput vector search.
Redis Vector Store
Redis supports vector similarity search through the RediSearch module, allowing reuse of existing Redis infrastructure.
| Configuration | Value |
|---|---|
VectorDb |
Redis |
ConnectionString |
Standard Redis connection string |
TableNamePrefix |
Not required |
Implementation Detail: In KMService.cs (lines 70-74), the configuration is applied via:
memory.WithRedisMemoryDb(new RedisConfig {
ConnectionString = ConnectionString
});
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "Redis",
"ConnectionString": "localhost:6379,password=MyRedisPwd,ssl=False"
}
}
Redis is suitable for environments already running Redis clusters or requiring hybrid vector and key-value storage.
PostgreSQL Vector Storage (Optional)
PostgreSQL with the pgvector extension provides relational vector storage.
| Configuration | Value |
|---|---|
VectorDb |
Postgres |
ConnectionString |
Standard PostgreSQL connection string |
TableNamePrefix |
Optional prefix for KM tables |
Implementation Detail: In KMService.cs (lines 44-50):
memory.WithPostgresMemoryDb(new PostgresConfig {
ConnectionString = ConnectionString,
TableNamePrefix = TableNamePrefix
});
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "Postgres",
"ConnectionString": "Host=localhost;Port=5432;Database=km;Username=km_user;Password=km_pwd",
"TableNamePrefix": "km_"
}
}
Azure AI Search (Optional)
Azure AI Search (formerly Cognitive Search) offers managed vector indexing.
| Configuration | Value |
|---|---|
VectorDb |
AzureAISearch |
ConnectionString |
`"{serviceEndpoint} |
TableNamePrefix |
Not required |
Implementation Detail: In KMService.cs (lines 75-78):
var aisearchConfig = ConnectionString.Split("|");
memory.WithAzureAISearchMemoryDb(aisearchConfig[0], aisearchConfig[1]);
Configuration Example:
{
"KernelMemoryOption": {
"VectorDb": "AzureAISearch",
"ConnectionString": "https://mysearch.search.windows.net|my-azure-search-key"
}
}
Implementation Architecture
The vector storage initialization follows a consistent pattern in KMService.cs. The WithMemoryDbByVectorDB method receives a KernelMemoryBuilder instance and applies the appropriate extension method based on the static KernelMemoryOption.VectorDb value.
Key source files:
src/AntSK.Domain/Options/KernelMemoryOption.cs– Defines the static configuration properties (VectorDb,ConnectionString,TableNamePrefix)src/AntSK.Domain/Domain/Service/KMService.cs– Contains theWithMemoryDbByVectorDBmethod (lines 37-79) that routes to specific vector store implementations
Summary
- AntSK uses Microsoft's Kernel Memory library for vector storage abstraction, configured through the static
KernelMemoryOptionclass. - Six vector storage providers are supported: Disk (file system), Memory (volatile RAM), Qdrant, Redis, PostgreSQL, and Azure AI Search.
- Configuration is runtime-based: Set
VectorDbto the provider name and provide aConnectionStringin the format required by that specific backend. - Qdrant and Azure AI Search use pipe-separated connection strings (
host|apiKey), while Redis and Postgres use standard connection string formats. - Disk and Memory require no connection strings, making them ideal for development or testing scenarios.
Frequently Asked Questions
How do I switch from Disk storage to Qdrant in AntSK?
Change the VectorDb value from "Disk" to "Qdrant" in your appsettings.json or environment variables, then provide the Qdrant endpoint and API key in the ConnectionString property using the pipe-separated format: "http://localhost:6333|your-api-key". No code changes are required in KMService.cs because the WithMemoryDbByVectorDB method routes automatically based on the configuration value.
What is the difference between Disk and Memory vector storage in AntSK?
Disk storage persists vectors as binary files on the local file system using FileSystemTypes.Disk, ensuring data survives application restarts but limiting scalability to single-node deployments. Memory storage uses FileSystemTypes.Volatile to keep all vectors in RAM, providing faster access but complete data loss when the process terminates, making it suitable only for testing or temporary caching.
Does AntSK support PostgreSQL for vector storage?
Yes, AntSK supports PostgreSQL with the pgvector extension through the Kernel Memory library. Set VectorDb to "Postgres" and provide a standard PostgreSQL connection string. You can optionally specify a TableNamePrefix to namespace the tables created by Kernel Memory. The implementation uses WithPostgresMemoryDb in KMService.cs (lines 44-50).
Is there a way to use Redis as a vector database in AntSK?
Yes, AntSK supports Redis as a vector store via the RediSearch module. Configure it by setting VectorDb to "Redis" and providing a standard Redis connection string (e.g., "localhost:6379,password=secret"). The KMService.WithMemoryDbByVectorDB method (lines 70-74) initializes the Redis backend using WithRedisMemoryDb with a RedisConfig object containing your connection string.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →