{
  "type": "module",
  "source": "doc/api/api-cachestore.md",
  "modules": [
    {
      "textRaw": "Cache Store",
      "name": "cache_store",
      "type": "module",
      "desc": "<p>A Cache Store is responsible for storing and retrieving cached responses.\nIt is also responsible for deciding which specific response to use based off of\na response's <code>Vary</code> header (if present). It is expected to be compliant with\n<a href=\"https://www.rfc-editor.org/rfc/rfc9111.html\">RFC-9111</a>.</p>",
      "modules": [
        {
          "textRaw": "Pre-built Cache Stores",
          "name": "pre-built_cache_stores",
          "type": "module",
          "modules": [
            {
              "textRaw": "`MemoryCacheStore`",
              "name": "`memorycachestore`",
              "type": "module",
              "desc": "<p>The <code>MemoryCacheStore</code> stores the responses in-memory.</p>\n<p><strong>Options</strong></p>\n<ul>\n<li><code>maxSize</code> - The maximum total size in bytes of all stored responses. Default <code>104857600</code> (100MB).</li>\n<li><code>maxCount</code> - The maximum amount of responses to store. Default <code>1024</code>.</li>\n<li><code>maxEntrySize</code> - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached. Default <code>5242880</code> (5MB).</li>\n</ul>",
              "displayName": "`MemoryCacheStore`"
            },
            {
              "textRaw": "Getters",
              "name": "getters",
              "type": "module",
              "properties": [
                {
                  "textRaw": "`MemoryCacheStore.size`",
                  "name": "size",
                  "type": "property",
                  "desc": "<p>Returns the current total size in bytes of all stored responses.</p>"
                }
              ],
              "displayName": "Getters"
            },
            {
              "textRaw": "Methods",
              "name": "methods",
              "type": "module",
              "methods": [
                {
                  "textRaw": "`MemoryCacheStore.isFull()`",
                  "name": "isFull",
                  "type": "method",
                  "signatures": [
                    {
                      "params": []
                    }
                  ],
                  "desc": "<p>Returns a boolean indicating whether the cache has reached its maximum size or count.</p>"
                }
              ],
              "displayName": "Methods"
            },
            {
              "textRaw": "Events",
              "name": "events",
              "type": "module",
              "modules": [
                {
                  "textRaw": "`'maxSizeExceeded'`",
                  "name": "`'maxsizeexceeded'`",
                  "type": "module",
                  "desc": "<p>Emitted when the cache exceeds its maximum size or count limits. The event payload contains <code>size</code>, <code>maxSize</code>, <code>count</code>, and <code>maxCount</code> properties.</p>",
                  "displayName": "`'maxSizeExceeded'`"
                }
              ],
              "displayName": "Events"
            },
            {
              "textRaw": "`SqliteCacheStore`",
              "name": "`sqlitecachestore`",
              "type": "module",
              "desc": "<p>The <code>SqliteCacheStore</code> stores the responses in a SQLite database.\nUnder the hood, it uses Node.js' <a href=\"https://nodejs.org/api/sqlite.html\"><code>node:sqlite</code></a> api.\nThe <code>SqliteCacheStore</code> is only exposed if the <code>node:sqlite</code> api is present.</p>\n<p><strong>Options</strong></p>\n<ul>\n<li><code>location</code> - The location of the SQLite database to use. Default <code>:memory:</code>.</li>\n<li><code>maxCount</code> - The maximum number of entries to store in the database. Default <code>Infinity</code>.</li>\n<li><code>maxEntrySize</code> - The maximum size in bytes that a response's body can be. If a response's body is greater than or equal to this, the response will not be cached. Default <code>Infinity</code>.</li>\n</ul>",
              "displayName": "`SqliteCacheStore`"
            }
          ],
          "displayName": "Pre-built Cache Stores"
        },
        {
          "textRaw": "Defining a Custom Cache Store",
          "name": "defining_a_custom_cache_store",
          "type": "module",
          "desc": "<p>The store must implement the following functions:</p>",
          "modules": [
            {
              "textRaw": "Getter: `isFull`",
              "name": "getter:_`isfull`",
              "type": "module",
              "desc": "<p>Optional. This tells the cache interceptor if the store is full or not. If this is true,\nthe cache interceptor will not attempt to cache the response.</p>",
              "displayName": "Getter: `isFull`"
            },
            {
              "textRaw": "Function: `get`",
              "name": "function:_`get`",
              "type": "module",
              "desc": "<p>Parameters:</p>\n<ul>\n<li><strong>req</strong> <code>Dispatcher.RequestOptions</code> - Incoming request</li>\n</ul>\n<p>Returns: <code>GetResult | Promise&#x3C;GetResult | undefined> | undefined</code> - If the request is cached, the cached response is returned. If the request's method is anything other than HEAD, the response is also returned.\nIf the request isn't cached, <code>undefined</code> is returned.</p>\n<p>The <code>get</code> method may return a <code>Promise</code> for async cache stores (e.g. Redis-backed or remote stores). The cache interceptor handles both synchronous and asynchronous return values, including in revalidation paths (304 Not Modified handling and stale-while-revalidate background revalidation).</p>\n<p>Response properties:</p>\n<ul>\n<li><strong>response</strong> <code>CacheValue</code> - The cached response data.</li>\n<li><strong>body</strong> <code>Readable | Iterable&#x3C;Buffer> | undefined</code> - The response's body. This can be an array of <code>Buffer</code> chunks (with a <code>.values()</code> method) or a <code>Readable</code> stream. Both formats are supported in all code paths, including 304 revalidation.</li>\n</ul>",
              "displayName": "Function: `get`"
            },
            {
              "textRaw": "Function: `createWriteStream`",
              "name": "function:_`createwritestream`",
              "type": "module",
              "desc": "<p>Parameters:</p>\n<ul>\n<li><strong>req</strong> <code>Dispatcher.RequestOptions</code> - Incoming request</li>\n<li><strong>value</strong> <code>CacheValue</code> - Response to store</li>\n</ul>\n<p>Returns: <code>Writable | undefined</code> - If the store is full, return <code>undefined</code>. Otherwise, return a writable so that the cache interceptor can stream the body and trailers to the store.</p>",
              "displayName": "Function: `createWriteStream`"
            }
          ],
          "displayName": "Defining a Custom Cache Store"
        },
        {
          "textRaw": "`CacheValue`",
          "name": "`cachevalue`",
          "type": "module",
          "desc": "<p>This is an interface containing the majority of a response's data (minus the body).</p>",
          "modules": [
            {
              "textRaw": "Property `statusCode`",
              "name": "property_`statuscode`",
              "type": "module",
              "desc": "<p><code>number</code> - The response's HTTP status code.</p>",
              "displayName": "Property `statusCode`"
            },
            {
              "textRaw": "Property `statusMessage`",
              "name": "property_`statusmessage`",
              "type": "module",
              "desc": "<p><code>string</code> - The response's HTTP status message.</p>",
              "displayName": "Property `statusMessage`"
            },
            {
              "textRaw": "Property `rawHeaders`",
              "name": "property_`rawheaders`",
              "type": "module",
              "desc": "<p><code>Buffer[]</code> - The response's headers.</p>",
              "displayName": "Property `rawHeaders`"
            },
            {
              "textRaw": "Property `vary`",
              "name": "property_`vary`",
              "type": "module",
              "desc": "<p><code>Record&#x3C;string, string | string[] | null> | undefined</code> - The headers defined by the response's <code>Vary</code> header\nand their respective values for later comparison. Values are <code>null</code> when the\nheader specified in <code>Vary</code> was not present in the original request. These <code>null</code>\nvalues are automatically filtered out during revalidation so they are not sent\nas request headers.</p>\n<p>For example, for a response like</p>\n<pre><code>Vary: content-encoding, accepts\ncontent-encoding: utf8\naccepts: application/json\n</code></pre>\n<p>This would be</p>\n<pre><code class=\"language-js\">{\n  'content-encoding': 'utf8',\n  accepts: 'application/json'\n}\n</code></pre>\n<p>If the original request did not include the <code>accepts</code> header:</p>\n<pre><code class=\"language-js\">{\n  'content-encoding': 'utf8',\n  accepts: null\n}\n</code></pre>",
              "displayName": "Property `vary`"
            },
            {
              "textRaw": "Property `cachedAt`",
              "name": "property_`cachedat`",
              "type": "module",
              "desc": "<p><code>number</code> - Time in millis that this value was cached.</p>",
              "displayName": "Property `cachedAt`"
            },
            {
              "textRaw": "Property `staleAt`",
              "name": "property_`staleat`",
              "type": "module",
              "desc": "<p><code>number</code> - Time in millis that this value is considered stale.</p>",
              "displayName": "Property `staleAt`"
            },
            {
              "textRaw": "Property `deleteAt`",
              "name": "property_`deleteat`",
              "type": "module",
              "desc": "<p><code>number</code> - Time in millis that this value is to be deleted from the cache. This\nis either the same sa staleAt or the <code>max-stale</code> caching directive.</p>\n<p>The store must not return a response after the time defined in this property.</p>",
              "displayName": "Property `deleteAt`"
            }
          ],
          "displayName": "`CacheValue`"
        },
        {
          "textRaw": "`CacheStoreReadable`",
          "name": "`cachestorereadable`",
          "type": "module",
          "desc": "<p>This extends Node's <a href=\"https://nodejs.org/api/stream.html#class-streamreadable\"><code>Readable</code></a>\nand defines extra properties relevant to the cache interceptor.</p>",
          "modules": [
            {
              "textRaw": "Getter: `value`",
              "name": "getter:_`value`",
              "type": "module",
              "desc": "<p>The response's <a href=\"/docs/docs/api/CacheStore.html#cachestorevalue\"><code>CacheStoreValue</code></a></p>",
              "displayName": "Getter: `value`"
            }
          ],
          "displayName": "`CacheStoreReadable`"
        },
        {
          "textRaw": "`CacheStoreWriteable`",
          "name": "`cachestorewriteable`",
          "type": "module",
          "desc": "<p>This extends Node's <a href=\"https://nodejs.org/api/stream.html#class-streamwritable\"><code>Writable</code></a>\nand defines extra properties relevant to the cache interceptor.</p>",
          "modules": [
            {
              "textRaw": "Setter: `rawTrailers`",
              "name": "setter:_`rawtrailers`",
              "type": "module",
              "desc": "<p>If the response has trailers, the cache interceptor will pass them to the cache\ninterceptor through this method.</p>",
              "displayName": "Setter: `rawTrailers`"
            }
          ],
          "displayName": "`CacheStoreWriteable`"
        }
      ],
      "displayName": "Cache Store"
    }
  ]
}