Documentation Index Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
Use this file to discover all available pages before exploring further.
Avoid re-indexing on every boot by using storage adapters. VectoriaDB supports file, Redis, and in-memory storage.
Storage Adapters
Adapter Use Case Persistence MemoryStorageAdapterDevelopment, testing None (default) FileStorageAdapterSingle-server deployment Local disk RedisStorageAdapterMulti-pod deployment Shared cache
File Adapter
Redis Adapter
Memory Adapter
Persist embeddings to local disk: import { VectoriaDB , FileStorageAdapter , SerializationUtils } from ' vectoriadb ' ;
const documents = collectToolDocuments ();
const toolIndex = new VectoriaDB < ToolDocument >({
storageAdapter : new FileStorageAdapter ({
cacheDir : ' ./.cache/vectoriadb ' ,
namespace : ' tool-index ' ,
}),
toolsHash : SerializationUtils . createToolsHash ( documents ),
version : process . env . npm_package_version ,
});
await toolIndex . initialize ();
if ( toolIndex . size () === 0 ) {
await toolIndex . addMany ( documents );
await toolIndex . saveToStorage (); // Persist to disk
}
File Adapter Options Option Type Default Description cacheDirstring ./.cache/vectoriadbDirectory for cache files namespacestring 'default'Namespace for isolation
For multi-pod environments, use Redis to share embeddings: import { VectoriaDB , RedisStorageAdapter } from ' vectoriadb ' ;
import Redis from ' ioredis ' ;
const redisClient = new Redis ();
const toolIndex = new VectoriaDB < ToolDocument >({
storageAdapter : new RedisStorageAdapter ({
client : redisClient ,
namespace : ' tool-index ' ,
ttl : 86400 , // 24 hours (default)
keyPrefix : ' vectoriadb ' ,
}),
});
await toolIndex . initialize ();
if ( toolIndex . size () === 0 ) {
await toolIndex . addMany ( documents );
await toolIndex . saveToStorage ();
}
Redis Adapter Options Option Type Default Description clientRedis required ioredis client instance namespacestring 'default'Namespace for isolation ttlnumber 86400Time-to-live in seconds keyPrefixstring 'vectoriadb'Redis key prefix
No persistence - embeddings are lost on restart: import { VectoriaDB , MemoryStorageAdapter } from ' vectoriadb ' ;
const toolIndex = new VectoriaDB < ToolDocument >({
storageAdapter : new MemoryStorageAdapter ({ namespace : ' tools ' }),
});
Use for development or when re-indexing is fast enough.
Cache Invalidation
VectoriaDB automatically invalidates the cache when documents change. Use toolsHash and version to control invalidation:
const toolIndex = new VectoriaDB < ToolDocument >({
storageAdapter : new FileStorageAdapter ({ cacheDir : ' ./.cache ' }),
// Hash of document contents - invalidates when documents change
toolsHash : SerializationUtils . createToolsHash ( documents ),
// Application version - invalidates on deployments
version : process . env . npm_package_version ,
});
How Invalidation Works
On initialize(), VectoriaDB checks:
Does the cache file/key exist?
Does toolsHash match?
Does version match?
Does modelName match?
If any check fails, the cache is invalidated and re-indexing occurs.
Warm-up Pattern
Common pattern for production deployments:
export async function warmToolIndex ( documents : ToolDocument []) {
const toolIndex = new VectoriaDB < ToolDocument >({
storageAdapter : new FileStorageAdapter ({
cacheDir : ' ./.cache/vectoriadb ' ,
namespace : ' tool-index ' ,
}),
toolsHash : SerializationUtils . createToolsHash ( documents ),
version : process . env . npm_package_version ,
});
await toolIndex . initialize ();
// Only re-index if cache was invalidated
if ( toolIndex . size () === 0 ) {
console . log ( ' Cache miss - re-indexing... ' );
await toolIndex . addMany ( documents );
await toolIndex . saveToStorage ();
} else {
console . log ( ' Cache hit - loaded from storage ' );
}
return toolIndex ;
}
Manual Storage Operations
// Save current state to storage
await toolIndex . saveToStorage ();
// Load from storage (done automatically on initialize)
await toolIndex . loadFromStorage ();
// Clear storage
await toolIndex . clearStorage ();
Multi-Tenant Isolation
Use namespaces to isolate different indexes:
// Tenant A
const tenantAIndex = new VectoriaDB ({
storageAdapter : new RedisStorageAdapter ({
client : redisClient ,
namespace : ' tenant-a ' ,
}),
});
// Tenant B
const tenantBIndex = new VectoriaDB ({
storageAdapter : new RedisStorageAdapter ({
client : redisClient ,
namespace : ' tenant-b ' ,
}),
});
Error Handling
import { StorageError } from ' vectoriadb ' ;
try {
await toolIndex . saveToStorage ();
} catch ( error ) {
if ( error instanceof StorageError ) {
console . error ( ' Storage operation failed: ' , error . message );
// Fallback to in-memory only
}
}
HNSW Scaling with HNSW index