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

# Buffer Window Memory

Use 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="https://662370747-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3VoWwSsyrEg0DEvIIjv9%2Fuploads%2Fgit-blob-a669684b08edb212063bbe87e3cc2d168c9c1b62%2Fimage%20(1)%20(1)%20(3)%20(1).png?alt=media" 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 |
