Overview
Memori performs memory operations asynchronously to avoid blocking your application. This guide covers async patterns and best practices.Async LLM Calls
- Python
- TypeScript
Async Recall
Manually recall memories asynchronously.- Python
- TypeScript
Concurrent Operations
Handle multiple memory operations in parallel.- Python
- TypeScript
Waiting for Augmentation
In short-lived applications (CLI tools, scripts), wait for memory processing to complete.- Python
- TypeScript
Async Web Server
In long-running servers, you don’t need to wait for augmentation.- Python (FastAPI)
- TypeScript (Express)
Background Tasks
Process memories in background tasks for better performance.Custom Embeddings (Async)
Generate embeddings asynchronously for better performance.- Python
- TypeScript
Error Handling
Handle async errors gracefully.Best Practices
Wait in Scripts
Always call
mem.augmentation.wait() in short-lived CLI tools and scripts.Don't Wait in Servers
Long-running servers don’t need to wait - memory processing happens in background.
Parallel Operations
Use
Promise.all() or asyncio.gather() for concurrent operations.Handle Errors
Wrap async operations in try-catch blocks to prevent unhandled rejections.
Performance Tips
Avoid Blocking Operations
Memori operations are async - don’t block the event loop with synchronous code.
Next Steps
Custom Embeddings
Use custom embedding models
Basic Memory
Review basic memory operations