> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# distributed_cache_* 会话设置

> ClickHouse 在 distributed_cache_* 自动生成分组中的会话设置。

这些设置可在 [system.settings](https://clickhouse.com/docs/zh/reference/system-tables/settings.md) 中找到，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

## distributed\_cache\_alignment

类型

UInt64

默认值

0

仅在 ClickHouse Cloud 中生效。此设置仅用于测试，请勿更改

## distributed\_cache\_bypass\_connection\_pool

类型

Bool

默认值

0

仅在 ClickHouse Cloud 中生效。允许绕过分布式缓存连接池。

## distributed\_cache\_client\_id

仅在 ClickHouse Cloud 中生效。此设置仅用于 CI 测试：非空时，会覆盖 registry 中为该查询请求配置的分布式缓存客户端 ID。它使测试能够将数据分布在一组数量有限的客户端 ID 上，同时确保相同的数据始终位于同一客户端 ID 上。要求在分布式缓存客户端配置中启用 `ci_mode`：如果未启用 (默认情况，例如在生产环境中) ，通过分布式缓存路由读写的查询将以 `SUPPORT_IS_DISABLED` 失败，而不会静默回退到已配置的客户端 ID。从不访问分布式缓存的查询不受影响，因此会忽略此值。

## distributed\_cache\_connect\_backoff\_max\_ms

类型

UInt64

默认值

50

仅在 ClickHouse Cloud 中生效。分布式缓存创建连接时的最大退避毫秒数。

## distributed\_cache\_connect\_backoff\_min\_ms

类型

UInt64

默认值

0

仅在 ClickHouse Cloud 中生效。分布式缓存创建连接时的最小退避毫秒数。

## distributed\_cache\_connect\_max\_tries

类型

UInt64

默认值

5

仅在 ClickHouse Cloud 中生效。连接分布式缓存失败时的重试次数

## distributed\_cache\_connect\_timeout\_ms

类型

UInt64

默认值

50

仅在 ClickHouse Cloud 中生效。连接到 Distributed Cache 服务器时的连接超时。

## distributed\_cache\_credentials\_refresh\_period\_seconds

类型

UInt64

默认值

5

仅在 ClickHouse Cloud 中生效。凭证刷新周期。

## distributed\_cache\_data\_packet\_ack\_window

类型

UInt64

默认值

5

仅在 ClickHouse Cloud 中生效。用于在单个分布式缓存读取请求中为 DataPacket 序列发送 ACK 的窗口大小

## distributed\_cache\_discard\_connection\_if\_unread\_data

类型

Bool

默认值

1

仅在 ClickHouse Cloud 中生效。如果存在未读取的数据，则断开连接。

## distributed\_cache\_fetch\_metrics\_only\_from\_current\_az

类型

Bool

默认值

1

仅在 ClickHouse Cloud 中生效。在 system.distributed\_cache\_metrics 和 system.distributed\_cache\_events 中，仅从当前可用区拉取指标。

## distributed\_cache\_file\_cache\_name

仅在 ClickHouse Cloud 中生效。此设置仅用于 CI 测试，用于指定分布式缓存使用的文件系统缓存名称。

## distributed\_cache\_log\_mode

类型

DistributedCacheLogMode

默认值

on\_error

仅在 ClickHouse Cloud 中生效。用于写入 system.distributed\_cache\_log 的模式

## distributed\_cache\_max\_unacked\_inflight\_packets

类型

UInt64

默认值

10

仅在 ClickHouse Cloud 中生效。单个分布式缓存读取请求中处于传输中的未确认数据包的最大数量

## distributed\_cache\_min\_bytes\_for\_seek

类型

UInt64

默认值

0

仅在 ClickHouse Cloud 中生效。分布式缓存中执行寻道的最小字节数。

## distributed\_cache\_min\_inflight\_bytes\_to\_discard\_connection\_on\_seek

类型

UInt64

默认值

4194304

仅在 ClickHouse Cloud 中有效。当从已打开的分布式缓存 stream 的当前位置寻道至其他位置时，如果为继续通过读取范围 ID 机制重用连接而需丢弃的预估在途字节数超过此值，则会丢弃该连接并新建连接。这样可避免在频繁寻道时排空大量未使用的数据。设为 0 可禁用此功能，并始终重用连接。

## distributed\_cache\_pool\_behaviour\_on\_limit

类型

DistributedCachePoolBehaviourOnLimit

默认值

wait

仅在 ClickHouse Cloud 中生效。用于指定分布式缓存连接在达到连接池限制时的行为

## distributed\_cache\_prefer\_bigger\_buffer\_size

类型

Bool

默认值

0

仅在 ClickHouse Cloud 中有效。与 filesystem\_cache\_prefer\_bigger\_buffer\_size 相同，但适用于分布式缓存。

## distributed\_cache\_read\_only\_from\_current\_az

类型

Bool

默认值

1

仅在 ClickHouse Cloud 中生效。允许只从当前可用区读取数据。若禁用，则会从所有可用区中的所有缓存服务器读取。

## distributed\_cache\_read\_request\_max\_tries

类型

UInt64

默认值

10

仅在 ClickHouse Cloud 中生效。分布式缓存读取请求失败时的最大重试次数

## distributed\_cache\_receive\_response\_wait\_milliseconds

类型

UInt64

默认值

60000

仅在 ClickHouse Cloud 中生效。从分布式缓存接收请求数据的等待时间 (毫秒) 。

## distributed\_cache\_receive\_timeout\_milliseconds

类型

UInt64

默认值

10000

仅在 ClickHouse Cloud 中生效。以毫秒为单位，表示从分布式缓存接收任意类型响应的等待时间。

Cloud 默认值：`20000`。

## distributed\_cache\_receive\_timeout\_ms

类型

UInt64

默认值

3000

仅在 ClickHouse Cloud 中生效。该设置表示从 Distributed Cache 服务器接收数据的超时时间，单位为毫秒。如果在此时间间隔内未接收到任何字节，则会抛出异常。

## distributed\_cache\_registry\_show\_certificate\_and\_signature

类型

Bool

默认值

0

仅在 ClickHouse Cloud 中生效。显示 `system.distributed_cache_registry` 表中的 `certificate` 和 `signature` 列。默认情况下，这些列为空，以保持输出简洁；启用此设置可查看其内容。

## distributed\_cache\_send\_timeout\_ms

类型

UInt64

默认值

3000

仅在 ClickHouse Cloud 中生效。向 Distributed Cache 服务器发送数据的超时时间，单位为毫秒。如果客户端需要发送数据，但在此时间间隔内无法发送任何字节，则会抛出异常。

## distributed\_cache\_tcp\_keep\_alive\_timeout\_ms

类型

UInt64

默认值

2900

仅在 ClickHouse Cloud 中生效。该值表示在 TCP 开始发送 keepalive 探测之前，与 Distributed Cache 服务器的连接需保持空闲的时间 (毫秒) 。

## distributed\_cache\_throw\_on\_error

类型

Bool

默认值

0

仅在 ClickHouse Cloud 中生效。若在与分布式缓存通信期间发生异常，或收到来自分布式缓存的异常，则重新抛出该异常。否则，出错时回退为跳过分布式缓存。

## distributed\_cache\_use\_clients\_cache\_for\_read

类型

Bool

默认值

1

仅在 ClickHouse Cloud 中生效。对读取请求使用 clients cache。

## distributed\_cache\_wait\_connection\_from\_pool\_milliseconds

类型

UInt64

默认值

100

仅在 ClickHouse Cloud 中生效。当 distributed\_cache\_pool\_behaviour\_on\_limit 为 wait 时，表示从连接池中获取连接的等待时间，单位为毫秒。

## distributed\_cache\_write\_request\_max\_tries

类型

UInt64

默认值

10

仅在 ClickHouse Cloud 中生效。分布式缓存写入请求失败时的重试次数
