blob: db939a4d045020f3acf3e8668bfd6b49227c61c7 [file] [log] [blame]
<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-development/extensions-contrib/redis-cache" data-has-hydrated="false">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.4.3">
<title data-rh="true">Druid Redis Cache | Apache® Druid</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" name="twitter:image" content="https://druid.apache.org/img/druid_nav.png"><meta data-rh="true" property="og:url" content="https://druid.apache.org/docs/29.0.0/development/extensions-contrib/redis-cache"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Druid Redis Cache | Apache® Druid"><meta data-rh="true" name="description" content="&lt;!--"><meta data-rh="true" property="og:description" content="&lt;!--"><link data-rh="true" rel="icon" href="/img/favicon.png"><link data-rh="true" rel="canonical" href="https://druid.apache.org/docs/29.0.0/development/extensions-contrib/redis-cache"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/29.0.0/development/extensions-contrib/redis-cache" hreflang="en"><link data-rh="true" rel="alternate" href="https://druid.apache.org/docs/29.0.0/development/extensions-contrib/redis-cache" hreflang="x-default"><link rel="preconnect" href="https://www.google-analytics.com">
<link rel="preconnect" href="https://www.googletagmanager.com">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script>
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","UA-131010415-1",{})</script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js"></script><link rel="stylesheet" href="/assets/css/styles.4b88a1d0.css">
<link rel="preload" href="/assets/js/runtime~main.fc3ed64b.js" as="script">
<link rel="preload" href="/assets/js/main.9edfa408.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}return t}()||function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--dark"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/druid_nav.png" alt="Apache® Druid" class="themedImage_ToTc themedImage--dark_i4oU"></div></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/technology">Technology</a><a class="navbar__item navbar__link" href="/use-cases">Use Cases</a><a class="navbar__item navbar__link" href="/druid-powered">Powered By</a><a class="navbar__item navbar__link" href="/docs/29.0.0/design/">Docs</a><a class="navbar__item navbar__link" href="/community/">Community</a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache®</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://apachecon.com/?ref=druid.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">Security<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<svg width="12" height="12" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><a class="navbar__item navbar__link" href="/downloads/">Download</a><div class="searchBox_ZlJk"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input type="search" id="search_input_react" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><main class="docMainContainer_gTbr docMainContainerEnhanced_Uz_u"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Druid Redis Cache</h1></header><p>A cache implementation for Druid based on <a href="https://github.com/redis/redis" target="_blank" rel="noopener noreferrer">Redis</a>.</p><p>Below are guidance and configuration options known to this module.</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="installation">Installation<a href="#installation" class="hash-link" aria-label="Direct link to Installation" title="Direct link to Installation"></a></h2><p>Use <a href="/docs/29.0.0/operations/pull-deps">pull-deps</a> tool shipped with Druid to install this <a href="/docs/29.0.0/configuration/extensions#community-extensions">extension</a> on broker, historical and middle manager nodes.</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain">java -classpath </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;druid_dir/lib/*&quot;</span><span class="token plain"> org.apache.druid.cli.Main tools pull-deps -c org.apache.druid.extensions.contrib:druid-redis-cache:</span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain">VERSION</span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="enabling">Enabling<a href="#enabling" class="hash-link" aria-label="Direct link to Enabling" title="Direct link to Enabling"></a></h2><p>To enable this extension after installation,</p><ol><li><a href="/docs/29.0.0/configuration/extensions#loading-extensions">include</a> this <code>druid-redis-cache</code> extension</li><li>to enable cache on broker nodes, follow <a href="/docs/29.0.0/configuration/#broker-caching">broker caching docs</a> to set related properties</li><li>to enable cache on historical nodes, follow <a href="/docs/29.0.0/configuration/#historical-caching">historical caching docs</a> to set related properties</li><li>to enable cache on middle manager nodes, follow <a href="/docs/29.0.0/configuration/#peon-caching">peon caching docs</a> to set related properties</li><li>set <code>druid.cache.type</code> to <code>redis</code></li><li>add the following properties</li></ol><h2 class="anchor anchorWithStickyNavbar_LWe7" id="configuration">Configuration<a href="#configuration" class="hash-link" aria-label="Direct link to Configuration" title="Direct link to Configuration"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="cluster-mode">Cluster mode<a href="#cluster-mode" class="hash-link" aria-label="Direct link to Cluster mode" title="Direct link to Cluster mode"></a></h3><p>To utilize a redis cluster, following properties must be set.</p><p>Note: some redis cloud service providers provide redis cluster service via a redis proxy, for these clusters, please follow the <a href="#standalone-mode">Standalone mode</a> configuration below.</p><table><thead><tr><th>Properties</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><code>druid.cache.cluster.nodes</code></td><td>Redis nodes in a cluster, represented in comma separated string. See example below</td><td>None</td><td>yes</td></tr><tr><td><code>druid.cache.cluster.maxRedirection</code></td><td>Max retry count</td><td>5</td><td>no</td></tr></tbody></table><h4 class="anchor anchorWithStickyNavbar_LWe7" id="example">Example<a href="#example" class="hash-link" aria-label="Direct link to Example" title="Direct link to Example"></a></h4><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain"># a typical redis cluster with 6 nodes</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">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</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3 class="anchor anchorWithStickyNavbar_LWe7" id="standalone-mode">Standalone mode<a href="#standalone-mode" class="hash-link" aria-label="Direct link to Standalone mode" title="Direct link to Standalone mode"></a></h3><p>To use a standalone redis, following properties must be set.</p><table><thead><tr><th>Properties</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><code>druid.cache.host</code></td><td>Redis server host</td><td>None</td><td>yes</td></tr><tr><td><code>druid.cache.port</code></td><td>Redis server port</td><td>None</td><td>yes</td></tr><tr><td><code>druid.cache.database</code></td><td>Redis database index</td><td>0</td><td>no</td></tr></tbody></table><p>Note: if both <code>druid.cache.cluster.nodes</code> and <code>druid.cache.host</code> are provided, cluster mode is preferred.</p><h3 class="anchor anchorWithStickyNavbar_LWe7" id="shared-properties">Shared Properties<a href="#shared-properties" class="hash-link" aria-label="Direct link to Shared Properties" title="Direct link to Shared Properties"></a></h3><p>Except for the properties above, there are some extra properties which can be customized to meet different needs.</p><table><thead><tr><th>Properties</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td><code>druid.cache.password</code></td><td>Password to access redis server/cluster</td><td>None</td><td>no</td></tr><tr><td><code>druid.cache.expiration</code></td><td>Expiration for cache entries</td><td>P1D</td><td>no</td></tr><tr><td><code>druid.cache.timeout</code></td><td>Timeout for connecting to Redis and reading entries from Redis</td><td>PT2S</td><td>no</td></tr><tr><td><code>druid.cache.maxTotalConnections</code></td><td>Max total connections to Redis</td><td>8</td><td>no</td></tr><tr><td><code>druid.cache.maxIdleConnections</code></td><td>Max idle connections to Redis</td><td>8</td><td>no</td></tr><tr><td><code>druid.cache.minIdleConnections</code></td><td>Min idle connections to Redis</td><td>0</td><td>no</td></tr></tbody></table><p>For <code>druid.cache.expiration</code> and <code>druid.cache.timeout</code> properties, values can be format of <code>Period</code> or a number in milliseconds.</p><div class="language-properties codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#bfc7d5;--prism-background-color:#292d3e"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-properties codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#bfc7d5"><span class="token plain"># Period format(recomended)</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"># cache expires after 1 hour</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">druid.cache.expiration=PT1H</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"># or in number(milliseconds) format</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"># 1 hour = 3_600_000 milliseconds</span><br></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">druid.cache.expiration=3600000</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2 class="anchor anchorWithStickyNavbar_LWe7" id="metrics">Metrics<a href="#metrics" class="hash-link" aria-label="Direct link to Metrics" title="Direct link to Metrics"></a></h2><p>In addition to the normal cache metrics, the redis cache implementation also reports the following in both <code>total</code> and <code>delta</code></p><table><thead><tr><th>Metric</th><th>Description</th><th>Normal value</th></tr></thead><tbody><tr><td><code>query/cache/redis/*/requests</code></td><td>Count of requests to redis cache</td><td>whatever request to redis will increase request count by 1</td></tr></tbody></table></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#installation" class="table-of-contents__link toc-highlight">Installation</a></li><li><a href="#enabling" class="table-of-contents__link toc-highlight">Enabling</a></li><li><a href="#configuration" class="table-of-contents__link toc-highlight">Configuration</a><ul><li><a href="#cluster-mode" class="table-of-contents__link toc-highlight">Cluster mode</a></li><li><a href="#standalone-mode" class="table-of-contents__link toc-highlight">Standalone mode</a></li><li><a href="#shared-properties" class="table-of-contents__link toc-highlight">Shared Properties</a></li></ul></li><li><a href="#metrics" class="table-of-contents__link toc-highlight">Metrics</a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="footer__bottom text--center"><div class="margin-bottom--sm"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--light_HNdA footer__logo"><img src="/img/favicon.png" class="themedImage_ToTc themedImage--dark_i4oU footer__logo"></div><div class="footer__copyright">Copyright © 2023 Apache Software Foundation. Except where otherwise noted, licensed under CC BY-SA 4.0. Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.</div></div></div></footer></div>
<script src="/assets/js/runtime~main.fc3ed64b.js"></script>
<script src="/assets/js/main.9edfa408.js"></script>
</body>
</html>