> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # Mastra.listMemory() `.listMemory()` 方法返回 Mastra 实例中注册的所有 Memory 实例。 ## 使用示例 ```typescript const memoryInstances = mastra.listMemory() for (const [key, memory] of Object.entries(memoryInstances)) { console.log(`Memory "${key}": ${memory.id}`) } ``` ## 参数 此方法不接受任何参数。 ## 返回值 **memory** (`Record`): 包含所有已注册 Memory 实例的对象,以其注册键作为键。 ## 示例:检查已注册的 Memory ```typescript import { Mastra } from '@mastra/core' import { Memory } from '@mastra/memory' import { LibSQLStore } from '@mastra/libsql' const conversationMemory = new Memory({ id: 'conversation-memory', storage: new LibSQLStore({ id: 'conversation-store', url: ':memory:' }), }) const analyticsMemory = new Memory({ id: 'analytics-memory', storage: new LibSQLStore({ id: 'analytics-store', url: ':memory:' }), }) const mastra = new Mastra({ memory: { conversationMemory, analyticsMemory, }, }) // List all registered memory instances const allMemory = mastra.listMemory() console.log(Object.keys(allMemory)) // ["conversationMemory", "analyticsMemory"] ``` ## 相关内容 - [Mastra.getMemory()](https://mastra.zisheng.pro/reference/core/getMemory) - [Memory 概览](https://mastra.zisheng.pro/docs/memory/overview)