Project: Druid (App Definition and Development / Database)
File: redis-cache.md

id: redis-cache title: "Druid Redis Cache" <!-- ~ Licensed to the Apache Software Foundation (ASF) under one ~ or more contributor license agreements. See the NOTICE file ~ distributed with this work for additional information ~ regarding copyright ownership. The ASF licenses this file ~ to you under the Apache License, Version 2.0 (the ~ "License"); you may not use this file except in compliance ~ with the License. You may obtain a copy of the License at ~ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ ~ Unless required by applicable law or agreed to in writing, ~ software distributed under the License is distributed on an ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~ KIND, either express or implied. See the License for the ~ specific language governing permissions and limitations ~ under the License. --> A cache implementation for Druid based on . Below are guidance and configuration options known to this module. Use tool shipped with Druid to install this on broker, historical and middle manager nodes. ```bash java -classpath "druid_dir/lib/*" org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:druid-redis-cache:{VERSION} ``` To enable this extension after installation, this `druid-redis-cache` extension to enable cache on broker nodes, follow to set related properties to enable cache on historical nodes, follow to set related properties to enable cache on middle manager nodes, follow to set related properties set `druid.cache.type` to `redis` add the following properties To utilize a redis cluster, following properties must be set. Note: some redis cloud service providers provide redis cluster service via a redis proxy, for these clusters, please follow the configuration below. | Properties |Description|Default|Required| |--|--|-|--| |`druid.cache.cluster.nodes`| Redis nodes in a cluster, represented in comma separated string. See example below | None | yes | |`druid.cache.cluster.maxRedirection`| Max retry count | 5 | no | ```properties druid.cache.cluster.nodes=127.0.0.1:7001,127.0.0.1:7002,127.0.0.1:7003,127.0.0.1:7004,127.0.0.1:7005,127.0.0.1:7006 ``` To use a standalone redis, following properties must be set. | Properties |Description|Default|Required| |--|--|-|--| |`druid.cache.host`|Redis server host|None|yes| |`druid.cache.port`|Redis server port|None|yes| |`druid.cache.database`|Redis database index|0|no| Note: if both `druid.cache.cluster.nodes` and `druid.cache.host` are provided, cluster mode is preferred. Except for the properties above, there are some extra properties which can be customized to meet different needs. | Properties |Description|Default|Required| |--|--|-|--| |`druid.cache.password`| Password to access redis server/cluster | None |no| |`druid.cache.expiration`|Expiration for cache entries | P1D |no| |`druid.cache.timeout`|Timeout for connecting to Redis and reading entries from Redis|PT2S|no| |`druid.cache.maxTotalConnections`|Max total connections to Redis|8|no| |`druid.cache.maxIdleConnections`|Max idle connections to Redis|8|no| |`druid.cache.minIdleConnections`|Min idle connections to Redis|0|no| For `druid.cache.expiration` and `druid.cache.timeout` properties, values can be format of `Period` or a number in milliseconds. ```properties druid.cache.expiration=PT1H druid.cache.expiration=3600000 ``` In addition to the normal cache metrics, the redis cache implementation also reports the following in both `total` and `delta` |Metric|Description|Normal value| ||--|| |`query/cache/redis/*/requests`|Count of requests to redis cache|whatever request to redis will increase request count by 1|