Skip to main content

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.

File-based storage adapter for persisting embeddings to local disk.

Constructor

constructor(config?: FileStorageConfig)

FileStorageConfig

interface FileStorageConfig {
  cacheDir?: string;
  namespace?: string;
  fileName?: string;
}
OptionTypeDefaultDescription
cacheDirstring'./.cache/vectoriadb'Cache directory
namespacestring'default'Namespace for isolation
fileNamestring'embeddings.json'Cache file name

Example

import { VectoriaDB, FileStorageAdapter } from 'vectoriadb';

const db = new VectoriaDB({
  storageAdapter: new FileStorageAdapter({
    cacheDir: './.cache/vectoriadb',
    namespace: 'my-index',
  }),
});

File Structure

.cache/vectoriadb/
└── my-index/              # namespace
    └── embeddings.json    # cache file

Methods

All storage adapters implement the BaseStorageAdapter interface:
MethodDescription
initialize()Create cache directory
load()Load embeddings from file
save(data)Save embeddings to file
hasValidCache(metadata)Check if valid cache exists
clear()Delete cache file
close()Cleanup (no-op for file adapter)

Security

The adapter includes path traversal protection:
  • Namespace is sanitized to prevent directory escape
  • Resolved path is validated to stay within cacheDir

RedisStorageAdapter

Redis storage

MemoryStorageAdapter

Memory storage

Storage Guide

File adapter guide