> For the complete documentation index, see [llms.txt](https://docs.flowiseai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flowiseai.com/integrations/langchain/memory/buffer-window-memory.md).

# Buffer Window Memory

Use Flowise database table `chat_message` as the storage mechanism for storing/retrieving conversations.

Difference being it only fetches the last K interactions. This approach is beneficial for preserving a sliding window of the most recent interactions, ensuring the buffer remains manageable in size.

<figure><img src="/files/gksow6SkdNgCYchtxTCa" alt="" width="298"><figcaption></figcaption></figure>

## Input

| Parameter  | Description                                                                   | Default       |
| ---------- | ----------------------------------------------------------------------------- | ------------- |
| Size       | Last K messages to fetch                                                      | 4             |
| Session Id | An ID to retrieve/store messages. If not specified, a random ID will be used. |               |
| Memory Key | A key used to format messages in prompt template                              | chat\_history |
