> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/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/zh-TW/reference/core/getMemory) - [Memory 概覽](https://mastra.zisheng.pro/zh-TW/docs/memory/overview)