> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Mastra.getMemory() `.getMemory()` メソッドは、キーを使って Mastra レジストリから Memory インスタンスを取得します。Memory インスタンスは Mastra のコンストラクターで登録され、保存済みの Agent から参照できます。 ## 使用例 ```typescript const memory = mastra.getMemory('conversationMemory') // Use the memory instance const thread = await memory.createThread({ resourceId: 'user-123', title: 'New Conversation', }) ``` ## パラメーター **key** (`TMemoryKey extends keyof TMemory`): 取得する Memory インスタンスのレジストリキー。Mastra のコンストラクターで Memory を登録したときに使用したキーと一致する必要があります。 ## 戻り値 **memory** (`TMemory[TMemoryKey]`): 指定したキーの Memory インスタンス。Memory が見つからない場合はエラーをスローします。 ## 例: Memory の登録と取得 ```typescript import { Mastra } from '@mastra/core' import { Memory } from '@mastra/memory' import { LibSQLStore } from '@mastra/libsql' const conversationMemory = new Memory({ storage: new LibSQLStore({ id: 'conversation-store', url: ':memory:' }), }) const mastra = new Mastra({ memory: { conversationMemory, }, }) // Later, retrieve the memory instance const memory = mastra.getMemory('conversationMemory') ``` ## 関連項目 - [Mastra.listMemory()](https://mastra.zisheng.pro/ja/reference/core/listMemory) - [Memory の概要](https://mastra.zisheng.pro/ja/docs/memory/overview)