url
stringlengths 38
157
| content
stringlengths 72
15.1M
|
---|---|
https://redis.io/docs/latest/develop/tools/insight/release-notes/v1.14.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v1.14, may 2023
</h1>
<p class="text-lg -mt-5 mb-10">
RedisInsight v1.14.0
</p>
<h2 id="1140-may-2023">
1.14.0 (May 2023)
</h2>
<p>
RedisInsight version 1.X was retired on April 30, 2023, and will no longer be supported.
To continue using the best RedisInsight features and capabilities, download the latest RedisInsight version 2.Y from our
<a href="https://redis.com/redis-enterprise/redis-insight/">
website
</a>
or install it from an app store.
</p>
<p>
This is the maintenance release of RedisInsight 1.14 (v1.14.0).
</p>
<h2 id="headlines">
Headlines
</h2>
<ul>
<li>
Export connections to RedisInsight v2.
</li>
</ul>
<h2 id="details">
Details
</h2>
<h3 id="core">
Core
</h3>
<ul>
<li>
Added support for exporting database connections to easily migrate them to RedisInsight v2 by bulk exporting to a file.
</li>
<li>
Fixed Prompt verification bug for Sentinel instances.
</li>
</ul>
<h3 id="memory-analysis">
Memory analysis
</h3>
<ul>
<li>
Added support for
<code>
setlistpack
</code>
and
<code>
streamlistpack3
</code>
Redis 7 encoding types parsing.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/release-notes/v1.14.0/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/cms.initbyprob/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CMS.INITBYPROB
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CMS.INITBYPROB key error probability</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 2.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
</dl>
<p>
Initializes a Count-Min Sketch to accommodate requested tolerances.
</p>
<h3 id="parameters">
Parameters:
</h3>
<ul>
<li>
<strong>
key
</strong>
: The name of the sketch.
</li>
<li>
<strong>
error
</strong>
: Estimate size of error. The error is a percent of total counted
items. This effects the width of the sketch.
</li>
<li>
<strong>
probability
</strong>
: The desired probability for inflated count. This should
be a decimal value between 0 and 1. This effects the depth of the sketch.
For example, for a desired false positive rate of 0.1% (1 in 1000),
error_rate should be set to 0.001. The closer this number is to zero, the
greater the memory consumption per item and the more CPU usage per operation.
</li>
</ul>
<h2 id="return">
Return
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
-
<code>
OK
</code>
if executed correctly, or [] otherwise.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>redis> CMS.INITBYPROB test 0.001 0.01
OK
</code></pre>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cms.initbyprob/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-03-24/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes 7.2.4-12 (March 2024) release notes
</h1>
<p class="text-lg -mt-5 mb-10">
This is a maintenance release to support Redis Enterprise Software version 7.2.4-105.
</p>
<h2 id="highlights">
Highlights
</h2>
<p>
This is a maintenance release to support Redis Enterprise Software version 7.2.4-105.
</p>
<h2 id="new-in-this-release">
New in this release
</h2>
<h3 id="enhancements">
Enhancements
</h3>
<ul>
<li>
Added support for Redis Enterprise Software 7.2.4-105 (RED-113750)
</li>
</ul>
<h2 id="version-changes">
Version changes
</h2>
<p>
For a list of fixes related to CVEs, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/rs-7-2-4-105/#security">
Redis Enterprise 7.2.4-105 release notes
</a>
.
</p>
<h3 id="breaking-changes">
Breaking changes
</h3>
<p>
The following changes included in this release affect the upgrade process. Please read carefully before upgrading to 7.2.4-12.
</p>
<h4 id="upgrade-operating-system">
Upgrade operating system
</h4>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
If your databases use modules, you need to update all nodes in the cluster to Redis Enterprise 7.2.4 or later before upgrading your operating system. See
<a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-os/">
Upgrade a cluster's operating system
</a>
in the Redis Enterprise Software documentation for more details.
</div>
</div>
<h4 id="terminationgraceperiodseconds">
terminationGracePeriodSeconds
</h4>
<p>
The configurable
<code>
terminationGracePeriodSeconds
</code>
REC field has been added to replace the hard-coded timeout of 15 minutes for a node to be stopped/drained (RED-111471).
</p>
<h4 id="validatingwebhookconfiguration">
ValidatingWebhookConfiguration
</h4>
<p>
Versions 6.4.2-4 and later include a new
<code>
ValidatingWebhookConfiguration
</code>
resource to replace the
<code>
redb-admission
</code>
webhook resource. To use releases 6.4.2-4 or later, delete the old webhook resource and apply the new file. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#reapply-webhook">
upgrade Redis cluster
</a>
for instructions.
</p>
<h4 id="openshift-scc">
OpenShift SCC
</h4>
<p>
Versions 6.4.2-6 and later include a new SCC (
<code>
redis-enterprise-scc-v2
</code>
) that you need to bind to your service account before upgrading. OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later might get stuck if you skip this step. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading">
upgrade a Redis Enterprise cluster (REC)
</a>
for instructions.
</p>
<h3 id="upcoming-changes">
Upcoming changes
</h3>
<ul>
<li>
A future release of Redis Enterprise will remove support for RHEL7. We recommend migrating to RHEL8.
</li>
</ul>
<h3 id="supported-distributions">
Supported distributions
</h3>
<p>
The following table shows supported distributions at the time of this release. You can also find this list in
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
.
</p>
<p>
<span title="Check mark icon">
β
</span>
Supported β This distribution is supported for this version of Redis Enterprise Software for Kubernetes.
</p>
<p>
<span title="Warning icon">
β οΈ
</span>
Deprecated β This distribution is still supported for this version of Redis Enterprise Software for Kubernetes, but support will be removed in a future release.
</p>
<p>
<span title="X icon">
β
</span>
End of life β Support for this distribution ended.
</p>
<p>
Any distribution not listed below is not supported for production workloads.
</p>
<table>
<thead>
<tr>
<th>
<strong>
Kubernetes version
</strong>
</th>
<th>
<strong>
1.23
</strong>
</th>
<th>
<strong>
1.24
</strong>
</th>
<th>
<strong>
1.25
</strong>
</th>
<th>
<strong>
1.26
</strong>
</th>
<th>
<strong>
1.27
</strong>
</th>
<th>
<strong>
1.28
</strong>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Community Kubernetes
</td>
<td>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Amazon EKS
</td>
<td>
<span title="Deprecation warning">
β οΈ
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
Azure AKS
</td>
<td>
</td>
<td>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
Google GKE
</td>
<td>
<span title="X icon">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
Rancher 2.6
</td>
<td>
<span title="X icon">
β
</span>
</td>
<td>
<span title="X icon">
β
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
Rancher RKE2
</td>
<td>
<span title="Deprecation warning">
β οΈ
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
VMware TKG 2.1
</td>
<td>
<span title="Deprecation warning">
β οΈ
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
VMware TKG 2.2
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
VMware TKG 2.3
</td>
<td>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<strong>
OpenShift version
</strong>
</td>
<td>
<strong>
4.10
</strong>
</td>
<td>
<strong>
4.11
</strong>
</td>
<td>
<strong>
4.12
</strong>
</td>
<td>
<strong>
4.13
</strong>
</td>
<td>
<strong>
4.14
</strong>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
</tr>
<tr>
<td>
<strong>
VMware TKGI version
</strong>
</td>
<td>
<strong>
1.14
</strong>
</td>
<td>
<strong>
1.15
</strong>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<span title="X icon">
β
</span>
</td>
<td>
<span title="Supported">
β
</span>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<h2 id="downloads">
Downloads
</h2>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
redislabs/redis:7.2.4-105
</code>
</li>
<li>
<strong>
Operator
</strong>
:
<code>
redislabs/operator:7.2.4-12
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
redislabs/k8s-controller:7.2.4-12.
</code>
</li>
</ul>
<h4 id="openshift-images">
OpenShift images
</h4>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise:7.2.4-105.rhel8-openshift
</code>
(or
<code>
redislabs/redis-enterprise:7.2.4-105.rhel7-openshift
</code>
if upgrading from RHEL 7)
</li>
<li>
<strong>
Operator
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise-operator:7.2.4-12
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
registry.connect.redhat.com/redislabs/services-manager:7.2.4-12
</code>
</li>
</ul>
<h4 id="olm-bundle">
OLM bundle
</h4>
<p>
<strong>
Redis Enterprise operator bundle
</strong>
:
<code>
v7.2.4-12.6
</code>
</p>
<h2 id="known-limitations">
Known limitations
</h2>
<p>
The limitations below are specific to the Redis Enterprise for Kubernetes product. To view limitations for the supported Redis Enterprise Software version, see the
<a href="/docs/latest/operate/rs/release-notes/rs-7-2-4-releases/#known-limitations">
7.2.4 release notes
</a>
.
</p>
<h3 id="existing-limitations">
Existing limitations
</h3>
<ul>
<li>
<p>
<strong>
When modifying the database suffix for an Active-Active database, while the service-rigger is in a terminating state, the services-rigger will delete and create the ingress or route resources in a loop (RED-107687)
</strong>
Wait until the services- rigger pod has finished to terminate it.
</p>
</li>
<li>
<p>
<strong>
REAADB changes might fail with "gateway timeout" errors, mostly on OpenShift (RED-103048)
</strong>
Retry the operation.
</p>
</li>
<li>
<p>
<strong>
Creating two databases with the same name directly on Redis Enterprise software will cause the service to be deleted and the database will not be available (RED-99997)
</strong>
Avoid duplicating database names. Database creation via K8s has validation in place to prevent this.
</p>
</li>
<li>
<p>
<strong>
Installing the operator bundle produces warning:
<code>
Warning: would violate PodSecurity "restricted: v1.24"
</code>
(RED-97381)
</strong>
Ignore the warning. This issue is documented as benign on official Red Hat documentation.
</p>
</li>
<li>
<p>
<strong>
RERC resources must have a unique name (RED-96302)
</strong>
The string "rec-name"/"rec-namespace" must be different from all other participating clusters in the Active-Active database.
</p>
</li>
<li>
<p>
<strong>
Admission is not blocking REAADB with
<code>
shardCount
</code>
which exceeds license quota (RED-96301)
</strong>
Fix the problems with the REAADB and reapply.
</p>
</li>
<li>
<p>
<strong>
Active-Active controller only supports global database options. Configuration specific to location is not supported (RED-86490)
</strong>
</p>
</li>
<li>
<p>
<strong>
Active-Active setup removal might keep services or routes undeleted (RED-77752)
</strong>
Delete services or routes manually if you encounter this problem.
</p>
</li>
<li>
<p>
<strong>
<code>
autoUpgrade
</code>
set to
<code>
true
</code>
can cause unexpected bdb upgrades when
<code>
redisUpgradePolicy
</code>
is set to
<code>
true
</code>
(RED-72351)
</strong>
Contact support if your deployment is impacted.
</p>
</li>
<li>
<p>
<strong>
Following the previous quick start guide version causes issues with creating an REDB due to unrecognized memory field name (RED-69515)
</strong>
The workaround is to use the newer (current) revision of Deploy Redis Enterprise Software for Kubernetes.
</p>
</li>
<li>
<p>
<strong>
PVC size issues when using decimal value in spec (RED-62132)
</strong>
Make sure you use integer values for the PVC size.
</p>
</li>
<li>
<p>
<strong>
REC might report error states on initial startup (RED-61707)
</strong>
There is no workaround at this time except to ignore the errors.
</p>
</li>
<li>
<p>
<strong>
Hashicorp Vault integration - no support for Gesher (RED-55080)
</strong>
There is no workaround for this issue. Gesher support has been deprecated.
</p>
</li>
<li>
<p>
<strong>
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</strong>
When REC clusters are deployed on Kubernetes clusters without synchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
</li>
<li>
<p>
<strong>
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</strong>
When an REC cluster is deployed in a project (namespace) and has REDB resources, the REDB resources must be deleted first before the REC can be deleted. Therefore, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Then, you can delete the project.
</p>
</li>
<li>
<p>
<strong>
Clusters must be named 'rec' in OLM-based deployments (RED-39825)
</strong>
In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (namely, "rec"). The workaround is to name the cluster "rec".
</p>
</li>
<li>
<p>
<strong>
Readiness probe incorrect on failures (RED-39300)
</strong>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
</li>
<li>
<p>
<strong>
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</strong>
DNS conflicts are possible between the cluster
<code>
mdns_server
</code>
and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names.
</p>
</li>
<li>
<p>
<strong>
K8s-based 5.4.10 clusters seem to negatively affect existing 5.4.6 clusters (RED-37233)
</strong>
Upgrade clusters to latest version.
</p>
</li>
<li>
<p>
<strong>
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</strong>
In Kubernetes, the reported node CPU usage is the usage of the Kubernetes worker node hosting the REC pod.
</p>
</li>
<li>
<p>
<strong>
An unreachable cluster has status running (RED-32805)
</strong>
When a cluster is in an unreachable state, the state remains
<code>
running
</code>
instead of triggering an error.
</p>
</li>
<li>
<p>
<strong>
Long cluster names cause routes to be rejected (RED-25871)
</strong>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name exceeds 63 characters. The workaround is to limit the cluster name to 20 characters or fewer.
</p>
</li>
<li>
<p>
<strong>
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</strong>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/7-2-4-12-03-24/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/security/access-control/manage-users/login-lockout/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage user login
</h1>
<p class="text-lg -mt-5 mb-10">
Manage user login lockout and session timeout.
</p>
<p>
Redis Enterprise Software secures user access in a few different ways, including automatically:
</p>
<ul>
<li>
<p>
Locking user accounts after a series of authentication failures (invalid passwords)
</p>
</li>
<li>
<p>
Signing sessions out after a period of inactivity
</p>
</li>
</ul>
<p>
Here, you learn how to configure the relevant settings.
</p>
<h2 id="user-login-lockout">
User login lockout
</h2>
<p>
By default, after 5 failed login attempts within 15 minutes, the user account is locked for 30 minutes. You can change the user login lockout settings in the Cluster Manager UI or with
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/">
<code>
rladmin
</code>
</a>
.
</p>
<h3 id="view-login-lockout-settings">
View login lockout settings
</h3>
<p>
You can view the cluster's user login lockout settings from
<strong>
Cluster > Security > Preferences > Lockout threshold
</strong>
in the Cluster Manager UI or with
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/info/#info-cluster">
<code>
rladmin info cluster
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin info cluster <span class="p">|</span> grep login_lockout
</span></span><span class="line"><span class="cl"> login_lockout_counter_reset_after: <span class="m">900</span>
</span></span><span class="line"><span class="cl"> login_lockout_duration: <span class="m">1800</span>
</span></span><span class="line"><span class="cl"> login_lockout_threshold: <span class="m">5</span>
</span></span></code></pre>
</div>
<h3 id="configure-user-login-lockout">
Configure user login lockout
</h3>
<p>
To change the user login lockout settings using the Cluster Manager UI:
</p>
<ol>
<li>
<p>
Go to
<strong>
Cluster > Security > Preferences
</strong>
, then select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
Lockout threshold
</strong>
section, make sure the checkbox is selected.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/security-preferences-lockout-threshold.png" sdata-lightbox="/images/rs/screenshots/cluster/security-preferences-lockout-threshold.png">
<img alt="The Lockout threshold configuration section" src="/docs/latest/images/rs/screenshots/cluster/security-preferences-lockout-threshold.png"/>
</a>
</li>
<li>
<p>
Configure the following
<strong>
Lockout threshold
</strong>
settings:
</p>
<ol>
<li>
<p>
<strong>
Log-in attempts until user is revoked
</strong>
- The number of failed login attempts allowed before the user account is locked.
</p>
</li>
<li>
<p>
<strong>
Time between failed login attempts
</strong>
in seconds, minutes, or hours - The amount of time during which failed login attempts are counted.
</p>
</li>
<li>
<p>
For
<strong>
Unlock method
</strong>
, select one of the following:
</p>
<ul>
<li>
<p>
<strong>
Locked duration
</strong>
to set how long the user account is locked after excessive failed login attempts.
</p>
</li>
<li>
<p>
<strong>
Only Admin can unlock the user by resetting the password
</strong>
.
</p>
</li>
</ul>
</li>
</ol>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h3 id="change-allowed-login-attempts">
Change allowed login attempts
</h3>
<p>
To change the number of failed login attempts allowed before the user account is locked, use one of the following methods:
</p>
<ul>
<li>
<p>
<a href="#configure-user-login-lockout">
Cluster Manager UI
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-cluster">
<code>
rladmin tune cluster
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_threshold <integer>
</span></span></code></pre>
</div>
<p>
For example, to set the lockout threshold to 10 failed login attempts, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_threshold <span class="m">10</span>
</span></span></code></pre>
</div>
<p>
If you set the lockout threshold to 0, it turns off account lockout, and the cluster settings show
<code>
login_lockout_threshold: disabled
</code>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_threshold <span class="m">0</span>
</span></span></code></pre>
</div>
</li>
</ul>
<h3 id="change-time-before-login-attempts-reset">
Change time before login attempts reset
</h3>
<p>
To change the amount of time during which failed login attempts are counted, use one of the following methods:
</p>
<ul>
<li>
<p>
<a href="#configure-user-login-lockout">
Cluster Manager UI
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-cluster">
<code>
rladmin tune cluster
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_counter_reset_after <seconds>
</span></span></code></pre>
</div>
<p>
For example, to set the lockout reset to 1 hour, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_counter_reset_after <span class="m">3600</span>
</span></span></code></pre>
</div>
</li>
</ul>
<h3 id="change-login-lockout-duration">
Change login lockout duration
</h3>
<p>
To change the amount of time that the user account is locked after excessive failed login attempts, use one of the following methods:
</p>
<ul>
<li>
<p>
<a href="#configure-user-login-lockout">
Cluster Manager UI
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-cluster">
<code>
rladmin tune cluster
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_duration <login_lockout_duration>
</span></span></code></pre>
</div>
<p>
For example, to set the lockout duration to 1 hour, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_duration <span class="m">3600</span>
</span></span></code></pre>
</div>
<p>
If you set the lockout duration to 0, then the account can be unlocked only when an administrator changes the account's password.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_duration <span class="m">0</span>
</span></span></code></pre>
</div>
<p>
The cluster settings now show
<code>
login_lockout_duration: admin-release
</code>
.
</p>
</li>
</ul>
<h3 id="unlock-locked-user-accounts">
Unlock locked user accounts
</h3>
<p>
To unlock a user account in the Cluster Manager UI:
</p>
<ol>
<li>
<p>
Go to
<strong>
Access Control > Users
</strong>
. Locked users have a "User is locked out" label:
</p>
<a href="/docs/latest/images/rs/screenshots/access-control/users-locked-out.png" sdata-lightbox="/images/rs/screenshots/access-control/users-locked-out.png">
<img alt="The Access Control > Users configuration screen in the Cluster Manager UI" src="/docs/latest/images/rs/screenshots/access-control/users-locked-out.png"/>
</a>
</li>
<li>
<p>
Point to the user you want to unlock, then click
<strong>
Reset to unlock
</strong>
:
</p>
<a href="/docs/latest/images/rs/screenshots/access-control/users-reset-to-unlock.png" sdata-lightbox="/images/rs/screenshots/access-control/users-reset-to-unlock.png">
<img alt="Reset to unlock button appears when you point to a locked user in the list" src="/docs/latest/images/rs/screenshots/access-control/users-reset-to-unlock.png"/>
</a>
</li>
<li>
<p>
In the
<strong>
Reset user password
</strong>
dialog, enter a new password for the user:
</p>
<a href="/docs/latest/images/rs/screenshots/access-control/users-reset-user-password-dialog.png" sdata-lightbox="/images/rs/screenshots/access-control/users-reset-user-password-dialog.png">
<img alt="Reset user password dialog" src="/docs/latest/images/rs/screenshots/access-control/users-reset-user-password-dialog.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
to reset the user's password and unlock their account.
</p>
</li>
</ol>
<p>
To unlock a user account or reset a user password with
<code>
rladmin
</code>
, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster reset_password <user_email>
</span></span></code></pre>
</div>
<p>
To unlock a user account or reset a user password with the REST API, use
<a href="/docs/latest/operate/rs/references/rest-api/requests/users/#put-user">
<code>
PUT /v1/users
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT /v1/users
</span></span><span class="line"><span class="cl"><span class="o">{</span><span class="s2">"password"</span>: <span class="s2">"<new_password>"</span><span class="o">}</span>
</span></span></code></pre>
</div>
<h3 id="turn-off-login-lockout">
Turn off login lockout
</h3>
<p>
To turn off user login lockout and allow unlimited login attempts, use one of the following methods:
</p>
<ul>
<li>
<p>
Cluster Manager UI:
</p>
<ol>
<li>
<p>
Go to
<strong>
Cluster > Security > Preferences
</strong>
, then select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
Clear the
<strong>
Lockout threshold
</strong>
checkbox.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-cluster">
<code>
rladmin tune cluster
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune cluster login_lockout_threshold <span class="m">0</span>
</span></span></code></pre>
</div>
</li>
</ul>
<p>
The cluster settings show
<code>
login_lockout_threshold: disabled
</code>
.
</p>
<h2 id="configure-session-timeout">
Configure session timeout
</h2>
<p>
The Redis Enterprise Cluster Manager UI supports session timeouts. By default, users are automatically logged out after 15 minutes of inactivity.
</p>
<p>
To customize the session timeout, use one of the following methods:
</p>
<ul>
<li>
<p>
Cluster Manager UI:
</p>
<ol>
<li>
<p>
Go to
<strong>
Cluster > Security > Preferences
</strong>
, then select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
For
<strong>
Session timeout
</strong>
, select minutes or hours from the list and enter the timeout value.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/config/">
<code>
rladmin cluster config
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster config cm_session_timeout_minutes <number_of_min>
</span></span></code></pre>
</div>
<p>
The
<code>
<number_of_min>
</code>
is the number of minutes after which sessions will time out.
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/security/access-control/manage-users/login-lockout/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/compatibility/commands/server/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Server management commands compatibility
</h1>
<p class="text-lg -mt-5 mb-10">
Server management commands compatibility.
</p>
<p>
The following tables show which Redis Community Edition
<a href="/docs/latest/commands/?group=server">
server management commands
</a>
are compatible with standard and Active-Active databases in Redis Enterprise Software and Redis Cloud.
</p>
<h2 id="access-control-commands">
Access control commands
</h2>
<p>
Several access control list (ACL) commands are not available in Redis Enterprise. Instead, you can manage access controls from the
<a href="/docs/latest/operate/rs/security/access-control/">
Redis Enterprise Software Cluster Manager UI
</a>
and the
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/role-based-access-control/">
Redis Cloud console
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-cat/">
ACL CAT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-deluser/">
ACL DELUSER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-dryrun/">
ACL DRYRUN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Might reply with "unknown user" for LDAP users even if
<code>
AUTH
</code>
succeeds.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-genpass/">
ACL GENPASS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-getuser/">
ACL GETUSER
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-help/">
ACL HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-list/">
ACL LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-load/">
ACL LOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-log/">
ACL LOG
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-save/">
ACL SAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-setuser/">
ACL SETUSER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-users/">
ACL USERS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/acl-whoami/">
ACL WHOAMI
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
</tbody>
</table>
<h2 id="configuration-commands">
Configuration commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-get/">
CONFIG GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/compatibility/config-settings/">
Only supports a subset of configuration settings.
</a>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-resetstat/">
CONFIG RESETSTAT
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-rewrite/">
CONFIG REWRITE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/config-set/">
CONFIG SET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/compatibility/config-settings/">
Only supports a subset of configuration settings.
</a>
</td>
</tr>
</tbody>
</table>
<h2 id="general-server-commands">
General server commands
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command/">
COMMAND
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-count/">
COMMAND COUNT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-docs/">
COMMAND DOCS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-getkeys/">
COMMAND GETKEYS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-getkeysandflags/">
COMMAND GETKEYSANDFLAGS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-help/">
COMMAND HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-info/">
COMMAND INFO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/command-list/">
COMMAND LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/debug/">
DEBUG
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/flushall/">
FLUSHALL
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
*Can use the
<a href="/docs/latest/operate/rs/references/rest-api/requests/crdbs/flush/">
Active-Active flush API request
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/flushdb/">
FLUSHDB
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active*
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
*Can use the
<a href="/docs/latest/operate/rs/references/rest-api/requests/crdbs/flush/">
Active-Active flush API request
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lolwut/">
LOLWUT
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/shutdown/">
SHUTDOWN
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/swapdb/">
SWAPDB
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/time/">
TIME
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="module-commands">
Module commands
</h2>
<p>
For Redis Enterprise Software, you can
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/">
manage Redis modules
</a>
from the Cluster Manager UI or with
<a href="/docs/latest/operate/rs/references/rest-api/requests/modules/">
REST API requests
</a>
.
</p>
<p>
Redis Cloud manages modules for you and lets you
<a href="/docs/latest/operate/rc/databases/create-database/#modules">
enable modules
</a>
when you create a database.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-help/">
MODULE HELP
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-list/">
MODULE LIST
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-load/">
MODULE LOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-loadex/">
MODULE LOADEX
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/module-unload/">
MODULE UNLOAD
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="monitoring-commands">
Monitoring commands
</h2>
<p>
Although Redis Enterprise does not support certain monitoring commands, you can use the Cluster Manager UI to view Redis Enterprise Software
<a href="/docs/latest/operate/rs/clusters/monitoring/">
metrics
</a>
and
<a href="/docs/latest/operate/rs/clusters/logging/">
logs
</a>
or the Redis Cloud console to view Redis Cloud
<a href="/docs/latest/operate/rc/databases/monitor-performance/">
metrics
</a>
and
<a href="/docs/latest/operate/rc/logs-reports/system-logs/">
logs
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/dbsize/">
DBSIZE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/info/">
INFO
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
In Redis Enterprise,
<code>
INFO
</code>
returns a different set of fields than Redis Community Edition.
<br/>
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-doctor/">
LATENCY DOCTOR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-graph/">
LATENCY GRAPH
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-help/">
LATENCY HELP
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-histogram/">
LATENCY HISTOGRAM
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-history/">
LATENCY HISTORY
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-latest/">
LATENCY LATEST
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/latency-reset/">
LATENCY RESET
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-doctor/">
MEMORY DOCTOR
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-help/">
MEMORY HELP
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
in Redis versions earlier than 7.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-malloc-stats/">
MEMORY MALLOC-STATS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-purge/">
MEMORY PURGE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-stats/">
MEMORY STATS
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/memory-usage/">
MEMORY USAGE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
in Redis versions earlier than 7.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/monitor/">
MONITOR
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-get/">
SLOWLOG GET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-len/">
SLOWLOG LEN
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slowlog-reset/">
SLOWLOG RESET
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Standard
</span>
<br/>
<span title="Supported">
<nobr>
β
Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Not supported for
<a href="/docs/latest/develop/interact/programmability/">
scripts
</a>
.
</td>
</tr>
</tbody>
</table>
<h2 id="persistence-commands">
Persistence commands
</h2>
<p>
Data persistence and backup commands are not available in Redis Enterprise. Instead, you can
<a href="/docs/latest/operate/rs/databases/configure/database-persistence/">
manage data persistence
</a>
and
<a href="/docs/latest/operate/rs/databases/import-export/schedule-backups/">
backups
</a>
from the Redis Enterprise Software Cluster Manager UI and the
<a href="/docs/latest/operate/rc/databases/view-edit-database/#durability-section">
Redis Cloud console
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bgrewriteaof/">
BGREWRITEAOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/bgsave/">
BGSAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/lastsave/">
LASTSAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/save/">
SAVE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<h2 id="replication-commands">
Replication commands
</h2>
<p>
Redis Enterprise automatically manages
<a href="/docs/latest/operate/rs/databases/durability-ha/replication/">
replication
</a>
.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Command
</span>
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
<span style="min-width: 9em; display: table-cell">
Notes
</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/failover/">
FAILOVER
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/migrate/">
MIGRATE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/psync/">
PSYNC
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/replconf/">
REPLCONF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/replicaof/">
REPLICAOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/restore-asking/">
RESTORE-ASKING
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/role/">
ROLE
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/slaveof/">
SLAVEOF
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
Deprecated as of Redis v5.0.0.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/commands/sync/">
SYNC
</a>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
<span title="Not supported">
β Standard
</span>
<br/>
<span title="Not supported">
<nobr>
β Active-Active
</nobr>
</span>
</td>
<td style="text-align:left">
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/compatibility/commands/server/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/hset/.html | <section class="prose w-full py-12">
<h1 class="command-name">
HSET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">HSET key field value [field value ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) for each field/value pair added, so O(N) to add N field/value pairs when the command is called with multiple field/value pairs.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@hash
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Sets the specified fields to their respective values in the hash stored at
<code>
key
</code>
.
</p>
<p>
This command overwrites the values of specified fields that exist in the hash.
If
<code>
key
</code>
doesn't exist, a new key holding a hash is created.
</p>
<h2 id="examples">
Examples
</h2>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_hash-stephset">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_hash-stephset" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> HSET myhash field1 "Hello"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> HGET myhash field1
</span></span><span class="line hl"><span class="cl">"Hello"
</span></span><span class="line hl"><span class="cl">> HSET myhash field2 "Hi" field3 "World"
</span></span><span class="line hl"><span class="cl">(integer) 2
</span></span><span class="line hl"><span class="cl">> HGET myhash field2
</span></span><span class="line hl"><span class="cl">"Hi"
</span></span><span class="line hl"><span class="cl">> HGET myhash field3
</span></span><span class="line hl"><span class="cl">"World"
</span></span><span class="line hl"><span class="cl">> HGETALL myhash
</span></span><span class="line hl"><span class="cl">1) "field1"
</span></span><span class="line hl"><span class="cl">2) "Hello"
</span></span><span class="line hl"><span class="cl">3) "field2"
</span></span><span class="line hl"><span class="cl">4) "Hi"
</span></span><span class="line hl"><span class="cl">5) "field3"
</span></span><span class="line hl"><span class="cl">6) "World"</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_hash-stephset" title="Open example">
Python
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</span><span class="p">,</span> <span class="s2">"Hello"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> Hello</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="n">mapping</span><span class="o">=</span><span class="p">{</span><span class="s2">"field2"</span><span class="p">:</span> <span class="s2">"Hi"</span><span class="p">,</span> <span class="s2">"field3"</span><span class="p">:</span> <span class="s2">"World"</span><span class="p">})</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field2"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> Hi</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field3"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> World</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hgetall</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> { "field1": "Hello", "field2": "Hi", "field3": "World" }</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hset</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</span><span class="p">,</span> <span class="s2">"foo"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field1"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> foo</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res9</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">hget</span><span class="p">(</span><span class="s2">"myhash"</span><span class="p">,</span> <span class="s2">"field2"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res9</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> None</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_cmds_hash-stephset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_hash.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_hash-stephset" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'node:assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'Hello'</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// Hello
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'myhash'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'field2'</span><span class="o">:</span> <span class="s1">'Hi'</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s1">'field3'</span><span class="o">:</span> <span class="s1">'World'</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl"><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// Hi
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field3'</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// World
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGetAll</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hSet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">,</span> <span class="s1">'foo'</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field1'</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// foo
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">hGet</span><span class="p">(</span><span class="s1">'myhash'</span><span class="p">,</span> <span class="s1">'field2'</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// foo
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_cmds_hash-stephset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-hash.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_hash-stephset" title="Open example">
Java
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsHashExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hdel' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hexists' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hexpire' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hexpireat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hexpiretime' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hGetExampleParams</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line"><span class="cl"> <span class="n">hGetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field1"</span><span class="o">,</span> <span class="s">"foo"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">hGetResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="n">hGetExampleParams</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hGetResult1</span><span class="o">);</span> <span class="c1">// >>> 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">hGetResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hGetResult2</span><span class="o">);</span> <span class="c1">// >>> foo
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">hGetResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field2"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hGetResult3</span><span class="o">);</span> <span class="c1">// >>> null
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hget' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hgetall' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hincrby' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hincrbyfloat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hkeys' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hlen' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hmget' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hmset' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hpersist' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hpexpire' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hpexpireat' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hpexpiretime' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hpttl' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hrandfield' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hscan' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hSetExampleParams</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field1"</span><span class="o">,</span> <span class="s">"Hello"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">hSetResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="n">hSetExampleParams</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult1</span><span class="o">);</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">hSetResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field1"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult2</span><span class="o">);</span> <span class="c1">// >>> Hello
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field2"</span><span class="o">,</span> <span class="s">"Hi"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">hSetExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"field3"</span><span class="o">,</span> <span class="s">"World"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">hSetResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hset</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span><span class="n">hSetExampleParams</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult3</span><span class="o">);</span> <span class="c1">// >>> 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">hSetResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field2"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult4</span><span class="o">);</span> <span class="c1">// >>> Hi
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">hSetResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hget</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">,</span> <span class="s">"field3"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">hSetResult5</span><span class="o">);</span> <span class="c1">// >>> World
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">String</span><span class="o">></span> <span class="n">hSetResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">hgetAll</span><span class="o">(</span><span class="s">"myhash"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="n">String</span> <span class="n">key</span><span class="o">:</span> <span class="n">hSetResult6</span><span class="o">.</span><span class="na">keySet</span><span class="o">())</span> <span class="o">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Key: "</span> <span class="o">+</span> <span class="n">key</span> <span class="o">+</span> <span class="s">", Value: "</span> <span class="o">+</span> <span class="n">hSetResult6</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="n">key</span><span class="o">));</span>
</span></span><span class="line hl"><span class="cl"> <span class="o">}</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> Key: field3, Value: World
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Key: field2, Value: Hi
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Key: field1, Value: Hello
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hset' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hsetnx' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hstrlen' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'httl' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hvals' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_cmds_hash-stephset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsHashExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_hash-stephset" title="Open example">
Go
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_hset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// >>> Hello
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"field2"</span><span class="p">,</span> <span class="s">"Hi"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"field3"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// >>> 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// >>> Hi
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// >>> World
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGetAll</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> map[field1:Hello field2:Hi field3:World]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_hget</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"foo"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// >>> foo
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">HGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// >>> <empty string>
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_cmds_hash-stephset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_hash_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_hash-stephset" name="cmds_hash-stephset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_hash-stephset" title="Open example">
C#
</label>
<div aria-labelledby="tab-cmds_hash-stephset" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_hash-stephset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsHashExample</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">bool</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"foo"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// >>> foo</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// >>> Null</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hget' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">,</span> <span class="s">"Hello"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field1"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span> <span class="c1">// >>> Hello</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">HashSet</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"myhash"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"field2"</span><span class="p">,</span> <span class="s">"Hi"</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">HashEntry</span><span class="p">(</span><span class="s">"field3"</span><span class="p">,</span> <span class="s">"World"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">);</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field2"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span> <span class="c1">// >>> Hi</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">RedisValue</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGet</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">,</span> <span class="s">"field3"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// >>> World</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">HashEntry</span><span class="p">[]</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">HashGetAll</span><span class="p">(</span><span class="s">"myhash"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", res8.Select(h => $"</span><span class="p">{</span><span class="n">h</span><span class="p">.</span><span class="n">Name</span><span class="p">}:</span> <span class="p">{</span><span class="n">h</span><span class="p">.</span><span class="n">Value</span><span class="p">}</span><span class="s">"))}"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> field1: Hello, field2: Hi, field3: World</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'hset' step.</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_hash-stephset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_cmds_hash-stephset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsHashExample.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
Give these commands a try in the interactive console:
</p>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> HSET myhash field1 "Hello"
(integer) 1
redis> HGET myhash field1
"Hello"
redis> HSET myhash field2 "Hi" field3 "World"
(integer) 2
redis> HGET myhash field2
"Hi"
redis> HGET myhash field3
"World"
redis> HGETALL myhash
1) "field1"
2) "Hello"
3) "field2"
4) "Hi"
5) "field3"
6) "World"
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of fields that were added.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 4.0.0: Accepts multiple
<code>
field
</code>
and
<code>
value
</code>
arguments.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/hset/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/release-notes/previous-releases/k8s-6-0-12-5/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes Release Notes 6.0.12-5 (February 2021)
</h1>
<p class="text-lg -mt-5 mb-10">
Support for RS 6.0.12-57, Amazon Kubernetes Service (AKS), and role permissions on custom resources.
</p>
<p>
The Redis Enterprise
<a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/releases/tag/v6.0.12-5">
K8s 6.0.12-5
</a>
release is a
<em>
major release
</em>
on top of
<a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/releases/tag/v6.0.8-20">
6.0.8-20
</a>
providing support for the
<a href="https://docs.redislabs.com/latest/rs/release-notes/rs-6-0-12-january-2021/">
Redis Enterprise Software release 6.0.12-57
</a>
and includes several enhancements and bug fixes.
</p>
<h2 id="overview">
Overview
</h2>
<p>
This release of the operator provides:
</p>
<ul>
<li>
New features
</li>
<li>
Various bug fixes
</li>
</ul>
<p>
To upgrade your deployment to this latest release, see
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/">
"Upgrade a Redis Enterprise cluster (REC) on Kubernetes"
</a>
.
</p>
<h2 id="images">
Images
</h2>
<p>
This release includes the following container images:
</p>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
: redislabs/redis:6.0.12-57 or redislabs/redis:6.0.12-57.rhel7-openshift
</li>
<li>
<strong>
Operator and Bootstrapper
</strong>
: redislabs/operator:6.0.12-5
</li>
<li>
<strong>
Services Rigger
</strong>
: redislabs/k8s-controller:6.0.12-5 or redislabs/services-manager:6.0.12-5 (Red Hat registry)
</li>
</ul>
<h2 id="new-features">
New features
</h2>
<ul>
<li>
<a href="https://azure.microsoft.com/en-us/services/kubernetes-service/">
Azure Kubernetes Service
</a>
(AKS) is now supported. (RED40323)
</li>
<li>
Database custom resources now support roles permissions (role to Redis ACL bindings). (RED49780)
</li>
</ul>
<h2 id="feature-improvements">
Feature Improvements
</h2>
<ul>
<li>
The license information has been added to the REC status. (RED43078)
</li>
<li>
<code>
kubectl get rec
</code>
now displays more information (i.e., added "NODES", "VERSION", "STATE", "SPEC STATUS"). (RED46428)
</li>
<li>
The
<code>
extraLabels
</code>
in the cluster spec now applies to the PV and PVC at creation. (RED48694)
</li>
<li>
Added
<a href="https://rancher.com/products/rancher/2.5">
Rancher 2.5
</a>
support. (RED50211)
</li>
<li>
Added K8s (Kops) 1.19 support. (RED50211)
</li>
<li>
Added
<a href="https://docs.openshift.com/container-platform/4.6/welcome/index.html">
OpenShift 4.6
</a>
support. (RED50495)
</li>
<li>
Database resources can now disable the default database user. (RED50215)
</li>
<li>
REC credentials no longer use environment variables in pods. (RED47969)
</li>
</ul>
<h2 id="important-fixes">
Important fixes
</h2>
<ul>
<li>
Fixed an issue where pods are stuck terminating during teardown. (RED44726)
</li>
<li>
Fixed an issue where pods are stuck terminating during cluster recovery. (RED43846)
</li>
<li>
Changed the operator logs to use human-readable dates and times. (RED39026)
</li>
<li>
Fixed the display of resources in the OLM (OpenShift). (RED48116)
</li>
<li>
Fixed backup configuration issue for GCS without a subdir. (RED49299)
</li>
</ul>
<h2 id="known-limitations">
Known limitations
</h2>
<h3 id="crashloopbackoff-causes-cluster-recovery-to-be-incomplete--red33713">
CrashLoopBackOff causes cluster recovery to be incomplete (RED33713)
</h3>
<p>
When a pod's status is
<code>
CrashLoopBackOff
</code>
and we run the cluster recovery, the process will not complete. The workaround is to delete the crashing pods manually. The recovery process will then continue.
</p>
<h3 id="long-cluster-names-cause-routes-to-be-rejected--red25871">
Long cluster names cause routes to be rejected (RED25871)
</h3>
<p>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name will exceed 63 characters. The workaround is to limit cluster name to 20 characters or fewer.
</p>
<h3 id="cluster-cr-rec-errors-are-not-reported-after-invalid-updates-red25542">
Cluster CR (REC) errors are not reported after invalid updates (RED25542)
</h3>
<p>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
<h3 id="an-unreachable-cluster-has-status-running-red32805">
An unreachable cluster has status running (RED32805)
</h3>
<p>
When a cluster is in an unreachable state, the state is still
<code>
running
</code>
instead of being reported as an error.
</p>
<h3 id="readiness-probe-incorrect-on-failures-red39300">
Readiness probe incorrect on failures (RED39300)
</h3>
<p>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on the node fails.
</p>
<h3 id="role-missing-on-replica-sets-red39002">
Role missing on replica sets (RED39002)
</h3>
<p>
The
<code>
redis-enterprise-operator
</code>
role is missing permission on replica sets.
</p>
<h3 id="private-registries-are-not-supported-on-openshift-311-red38579">
Private registries are not supported on OpenShift 3.11 (RED38579)
</h3>
<p>
Openshift 3.11 does not support DockerHub private registries. This is a known OpenShift issue.
</p>
<h3 id="internal-dns-and-kubernetes-dns-may-have-conflicts-red37462">
Internal DNS and Kubernetes DNS may have conflicts (RED37462)
</h3>
<p>
DNS conflicts are possible between the cluster mdns_server and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names.
</p>
<h3 id="5410-negatively-impacts-546-red37233">
5.4.10 negatively impacts 5.4.6 (RED37233)
</h3>
<p>
Kubernetes-based 5.4.10 deployments seem to negatively impact existing 5.4.6 deployments that share a Kubernetes cluster.
</p>
<h3 id="node-cpu-usage-is-reported-instead-of-pod-cpu-usage-red36884">
Node CPU usage is reported instead of pod CPU usage (RED36884)
</h3>
<p>
In Kubernetes, the node CPU usage we report on is the usage of the Kubernetes worker node hosting the REC pod.
</p>
<h3 id="clusters-must-be-named-rec-in-olm-based-deployments-red39825">
Clusters must be named "rec" in OLM-based deployments (RED39825)
</h3>
<p>
In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) is bound to a specific service account name (i.e., "rec"). The workaround is to name the cluster "rec".
</p>
<h3 id="master-pod-label-in-rancher-red42896">
Master pod label in Rancher (RED42896)
</h3>
<p>
The master pod is not always labeled in Rancher.
</p>
<h3 id="rec-clusters-fail-to-start-on-kubernetes-clusters-with-unsynchronized-clocks-red47254">
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED47254)
</h3>
<p>
When REC clusters are deployed on Kubernetes clusters with unsynchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
<h3 id="deleting-an-openshift-project-with-an-rec-deployed-may-hang-red47192">
Deleting an OpenShift project with an REC deployed may hang (RED47192)
</h3>
<p>
When a REC cluster is deployed in a project (namespace) and has REDB resources, the
REDB resources must be deleted first before the REC can be deleted. As such, until the
REDB resources are deleted, the project deletion will hang. The fix is to delete the
REDB resources first and the REC second. Afterwards, you may delete the project.
</p>
<h3 id="rec-extralabels-are-not-applied-to-pvcs-on-k8s-versions-115-or-older-red51921">
REC extraLabels are not applied to PVCs on K8s versions 1.15 or older (RED51921)
</h3>
<p>
In K8s 1.15 or older, the PVC labels come from the match selectors and not the
PVC templates. As such, these versions can not support PVC labels. If this feature
is required, the only fix is to upgrade the K8s cluster to a newer version.
</p>
<h2 id="compatibility-notes">
Compatibility Notes
</h2>
<ul>
<li>
OpenShift 4.6 and Rancher/kOps 1.19 are now supported.
</li>
<li>
Rancher 2.5 is now supported.
</li>
<li>
AKS (K8s 1.18) is now supported.
</li>
</ul>
<h2 id="deprecation-notice">
Deprecation notice
</h2>
<ul>
<li>
OpenShift 4.1, 4.2, and 4.3 are now deprecated.
</li>
<li>
GKE K8s version 1.14 is deprecated.
</li>
<li>
kOps 1.13 and 1.14 are deprecated.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/previous-releases/k8s-6-0-12-5/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/clusters/maintenance-mode/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Maintenance mode for cluster nodes
</h1>
<p class="text-lg -mt-5 mb-10">
Prepare a cluster node for maintenance.
</p>
<p>
Use maintenance mode to prevent data loss during hardware patching or operating system maintenance on Redis Enterprise servers. When maintenance mode is on, all shards move off of the node under maintenance and migrate to another available node.
</p>
<h2 id="activate-maintenance-mode">
Activate maintenance mode
</h2>
<p>
When you activate maintenance mode, Redis Enterprise does the following:
</p>
<ol>
<li>
<p>
Checks whether a shut down of the node will cause quorum loss. If so, maintenance mode will not turn on.
</p>
<p>
Maintenance mode does not protect against quorum loss. If you activate maintenance mode for the majority of nodes in a cluster and restart them simultaneously, quorum is lost, which can lead to data loss.
</p>
</li>
<li>
<p>
If no maintenance mode snapshots already exist or if you use
<code>
overwrite_snapshot
</code>
when you activate maintenance mode, Redis Enterprise creates a new node snapshot that records the node's shard and endpoint configuration.
</p>
</li>
<li>
<p>
Marks the node as a quorum node to prevent shards and endpoints from migrating to it.
</p>
<p>
At this point,
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/">
<code>
rladmin status
</code>
</a>
displays the node's shards field in yellow, which indicates that shards cannot migrate to the node.
</p>
<a href="/docs/latest/images/rs/maintenance_mode.png" sdata-lightbox="/images/rs/maintenance_mode.png">
<img src="/docs/latest/images/rs/maintenance_mode.png"/>
</a>
</li>
<li>
<p>
Migrates shards and binds endpoints to other nodes, when space is available.
</p>
</li>
</ol>
<p>
Maintenance mode does not demote a master node by default. The cluster elects a new master node when the original master node restarts.
</p>
<p>
Add the
<code>
demote_node
</code>
option to the
<code>
rladmin
</code>
command to
<a href="#demote-a-master-node">
demote a master node
</a>
when you activate maintenance mode.
</p>
<p>
To activate maintenance mode for a node, run the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on overwrite_snapshot
</span></span></code></pre>
</div>
<p>
You can start server maintenance if:
</p>
<ul>
<li>
<p>
All shards and endpoints have moved to other nodes
</p>
</li>
<li>
<p>
Enough nodes are still online to maintain quorum
</p>
</li>
</ul>
<h3 id="prevent-replica-shard-migration">
Prevent replica shard migration
</h3>
<p>
If you do not have enough resources available to move all of the shards to other nodes, you can turn maintenance mode on without migrating the replica shards.
</p>
<p>
Before you prevent replica shard migration during maintenance mode, consider the following effects:
</p>
<ul>
<li>
<p>
Replica shards remain on the node during maintenance.
</p>
</li>
<li>
<p>
If the maintenance node fails, the master shards do not have replica shards to maintain data redundancy and high availability.
</p>
</li>
<li>
<p>
Replica shards that remain on the node can still be promoted during failover to preserve availability.
</p>
</li>
</ul>
<p>
To activate maintenance mode without replica shard migration, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on evict_ha_replica disabled evict_active_active_replica disabled
</span></span></code></pre>
</div>
<h3 id="demote-a-master-node">
Demote a master node
</h3>
<p>
If maintenance might affect connectivity to the master node, you can demote the master node when you activate maintenance mode. This lets the cluster elect a new master node.
</p>
<p>
To demote a master node when activating maintenance mode, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode on demote_node
</span></span></code></pre>
</div>
<h3 id="verify-maintenance-mode-activation">
Verify maintenance mode activation
</h3>
<p>
To verify maintenance mode for a node, use
<code>
rladmin status
</code>
and review the node's shards field. If that value is displayed in yellow (shown earlier), then the node is in maintenance mode.
</p>
<p>
Avoid activating maintenance mode when it is already active. Maintenance mode activations stack. If you activate maintenance mode for a node that is already in maintenance mode, you will have to deactivate maintenance mode twice in order to restore full functionality.
</p>
<h2 id="deactivate-maintenance-mode">
Deactivate maintenance mode
</h2>
<p>
When you deactivate maintenance mode, Redis Enterprise:
</p>
<ol>
<li>
<p>
Loads a
<a href="#specify-a-snapshot">
specified node snapshot
</a>
or defaults to the latest maintenance mode snapshot.
</p>
</li>
<li>
<p>
Unmarks the node as a quorum node to allow shards and endpoints to migrate to the node.
</p>
</li>
<li>
<p>
Restores the shards and endpoints that were in the node at the time of the snapshot.
</p>
</li>
<li>
<p>
Deletes the snapshot.
</p>
</li>
</ol>
<p>
To deactivate maintenance mode after server maintenance, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off
</span></span></code></pre>
</div>
<p>
By default, a snapshot is required to deactivate maintenance mode. If the snapshot cannot be restored, deactivation is cancelled and the node remains in maintenance mode. In such events, it may be necessary to
<a href="#reset_node_status">
reset node status
</a>
.
</p>
<h3 id="specify-a-snapshot">
Specify a snapshot
</h3>
<p>
When you turn off maintenance mode, you can restore the node configuration from a maintenance mode snapshot or any snapshots previously created by
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/snapshot/#node-snapshot-create">
<code>
rladmin node <node_id> snapshot create
</code>
</a>
. If you do not specify a snapshot, Redis Enterprise uses the latest maintenance mode snapshot by default.
</p>
<p>
To get a list of available snapshots, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> snapshot list
</span></span></code></pre>
</div>
<p>
To specify a snapshot when you turn maintenance mode off, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off snapshot_name <snapshot_name>
</span></span></code></pre>
</div>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
If an error occurs when you turn on maintenance mode, the snapshot is not deleted.
When you rerun the command, use the snapshot from the initial attempt since it contains the original state of the node.
</div>
</div>
<h3 id="skip-shard-restoration">
Skip shard restoration
</h3>
<p>
You can prevent the migrated shards and endpoints from returning to the original node after you turn off maintenance mode.
</p>
<p>
To turn maintenance mode off and skip shard restoration, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <node_id> maintenance_mode off skip_shards_restore
</span></span></code></pre>
</div>
<h3 id="reset-node-status">
Reset node status
</h3>
<p>
In extreme cases, you may need to reset a node's status. Run the following commands to do so:
</p>
<pre tabindex="0"><code>$ rladmin tune node <node_id> max_listeners 100
$ rladmin tune node <node_id> quorum_only disabled
</code></pre>
<p>
Use these commands with caution. For best results, contact Support before running these commands.
</p>
<h2 id="cluster-status-example">
Cluster status example
</h2>
<p>
This example shows how the output of
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/">
<code>
rladmin status
</code>
</a>
changes when you turn on maintenance mode for a node.
</p>
<p>
The cluster status before turning on maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin status
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS
</span></span><span class="line"><span class="cl">*node:1 master 172.17.0.2 rp1_node1 2/100
</span></span><span class="line"><span class="cl">node:2 slave 172.17.0.4 rp3_node1 2/100
</span></span><span class="line"><span class="cl">node:3 slave 172.17.0.3 rp2_node1 0/100
</span></span></code></pre>
</div>
<p>
The cluster status after turning on maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin node <span class="m">2</span> maintenance_mode on
</span></span><span class="line"><span class="cl">Performing maintenance_on action on node:2: 0%
</span></span><span class="line"><span class="cl">created snapshot NodeSnapshot<<span class="nv">name</span><span class="o">=</span>maintenance_mode_2019-03-14_09-50-59,time<span class="o">=</span>None,node_uid<span class="o">=</span>2>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">node:2 will not accept any more shards
</span></span><span class="line"><span class="cl">Performing maintenance_on action on node:2: 100%
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redislabs@rp1_node1:/opt$ rladmin status
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS
</span></span><span class="line"><span class="cl">*node:1 master 172.17.0.2 rp1_node1 2/100
</span></span><span class="line"><span class="cl">node:2 slave 172.17.0.4 rp3_node1 0/0
</span></span><span class="line"><span class="cl">node:3 slave 172.17.0.3 rp2_node1 2/100
</span></span></code></pre>
</div>
<p>
After turning on maintenance mode for node 2, Redis Enterprise saves a snapshot of its configuration and then moves its shards and endpoints to node 3.
</p>
<p>
Now node 2 has
<code>
0/0
</code>
shards because shards cannot migrate to it while it is in maintenance mode.
</p>
<h2 id="maintenance-mode-rest-api">
Maintenance mode REST API
</h2>
<p>
You can also turn maintenance mode on or off using
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API requests
</a>
to
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/nodes/actions/#post-node-action">
<nobr>
POST
<code>
/nodes/{node_uid}/actions/{action}
</code>
</nobr>
</a>
.
</p>
<h3 id="activate-maintenance-mode-rest-api">
Activate maintenance mode (REST API)
</h3>
<p>
Use
<nobr>
<code>
POST /nodes/{node_uid}/actions/maintenance_on
</code>
</nobr>
to activate maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_on
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"overwrite_snapshot"</span>: true,
</span></span><span class="line"><span class="cl"> <span class="s2">"evict_ha_replica"</span>: true,
</span></span><span class="line"><span class="cl"> <span class="s2">"evict_active_active_replica"</span>: <span class="nb">true</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<p>
You can set
<code>
evict_ha_replica
</code>
and
<code>
evict_active_active_replica
</code>
to
<code>
false
</code>
to
<a href="#prevent-replica-shard-migration">
prevent replica shard migration
</a>
.
</p>
<p>
The
<code>
maintenance_on
</code>
request returns a JSON response body:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span><span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"<task-id-guid>"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="deactivate-maintenance-mode-rest-api">
Deactivate maintenance mode (REST API)
</h3>
<p>
Use
<nobr>
<code>
POST /nodes/{node_uid}/actions/maintenance_off
</code>
</nobr>
deactivate maintenance mode:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_off
</span></span><span class="line"><span class="cl"><span class="o">{</span> <span class="s2">"skip_shards_restore"</span>: <span class="nb">false</span> <span class="o">}</span>
</span></span></code></pre>
</div>
<p>
The
<code>
skip_shards_restore
</code>
boolean flag allows the
<code>
maintenance_off
</code>
action to
<a href="#skip-shard-restoration">
skip shard restoration
</a>
when set to
<code>
true
</code>
.
</p>
<p>
The
<code>
maintenance_off
</code>
request returns a JSON response body:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span><span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"<task-id-guid>"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="track-action-status">
Track action status
</h3>
<p>
You can send a request to
<a href="/docs/latest/operate/rs/7.4/references/rest-api/requests/nodes/actions/#get-node-action">
<nobr>
GET
<code>
/nodes/{node_uid}/actions/{action}
</code>
</nobr>
</a>
to track the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/action/">
status
</a>
of the
<code>
maintenance_on
</code>
and
<code>
maintenance_off
</code>
actions.
</p>
<p>
This request returns the status of the
<code>
maintenance_on
</code>
action:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">GET https://<hostname>:9443/v1/nodes/<node_id>/actions/maintenance_on
</span></span></code></pre>
</div>
<p>
The response body:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span><span class="s2">"completed"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"task_id"</span><span class="p">:</span><span class="s2">"38c7405b-26a7-4379-b84c-cab4b3db706d"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/clusters/maintenance-mode/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/networking/multi-ip-ipv6/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage IP addresses
</h1>
<p class="text-lg -mt-5 mb-10">
Information and requirements for using multiple IP addresses or IPv6 addresses with Redis Enterprise Software.
</p>
<p>
Redis Enterprise SoftwareΒ supports servers, instances, and VMs with
multiple IPv4 or IPv6 addresses.
</p>
<h2 id="traffic-overview">
Traffic overview
</h2>
<p>
Redis Enterprise Software traffic is divided into internal traffic and external traffic:
</p>
<ul>
<li>
<p>
"Internal traffic" refers to internal cluster communications, such as communications between the nodes for cluster management.
</p>
</li>
<li>
<p>
"External traffic" refers to communications between clients and databases and connections to the Cluster Manager UI.
</p>
</li>
</ul>
<p>
When only one IP address exists on a machine that serves as a Redis Enterprise node, it is used for both internal and external traffic.
</p>
<h2 id="multiple-ip-addresses">
Multiple IP addresses
</h2>
<p>
During node configuration on a machine with multiple IP addresses, you must assign one address for internal traffic and one or more other addresses for external traffic.
</p>
<p>
If the cluster uses IPv4 for internal traffic, all communication between cluster nodes uses IPv4 addresses. If the cluster uses IPv6 for internal traffic, all communication between cluster nodes uses IPv6 addresses.
</p>
<p>
To update IP address configuration after cluster setup, see
<a href="#change-internal-ip-address">
Change internal IP address
</a>
or
<a href="#configure-external-ip-addresses">
Configure external IP addresses
</a>
.
</p>
<h2 id="enable-ipv6-for-internal-traffic">
Enable IPv6 for internal traffic
</h2>
<p>
IPv6 for internal communication is supported only for new clusters with Redis Enterprise Software version 7.4.2 or later.
</p>
<p>
If the server has only IPv6 interfaces, IPv6 is automatically used for internal and external traffic. Otherwise, internal traffic uses IPv4 by default.
</p>
<p>
To use IPv6 for internal traffic on a machine with both IPv4 and IPv6 interfaces, set
<code>
use_internal_ipv6
</code>
to
<code>
true
</code>
when you create a cluster using the
<a href="/docs/latest/operate/rs/references/rest-api/requests/bootstrap/#post-bootstrap">
bootstrap REST API request
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/bootstrap/create_cluster
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"action"</span>: <span class="s2">"create_cluster"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"cluster"</span>: <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span>: <span class="s2">"cluster.fqdn"</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"credentials"</span>: <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"username"</span>: <span class="s2">"admin_username"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"password"</span>: <span class="s2">"admin_password"</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"node"</span>: <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"identity"</span>: <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"addr"</span>: <span class="s2">"2001:DB8::/32"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"external_addr"</span>: <span class="o">[</span><span class="s2">"2001:0db8:85a3:0000:0000:8a2e:0370:7334"</span><span class="o">]</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"use_internal_ipv6"</span>: <span class="nb">true</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>,
</span></span><span class="line"><span class="cl"> <span class="o">}</span>,
</span></span><span class="line"><span class="cl"> ...
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<p>
When other IPv6 nodes join a cluster that has
<code>
use_internal_ipv6
</code>
enabled, they automatically use IPv6 for internal traffic. Do not manually set
<code>
use_internal_ipv6
</code>
when joining a node to an existing IPv6 cluster, or a
<code>
NodeBootstrapError
</code>
can occur if the values do not match.
</p>
<p>
If you try to add a node without an IPv6 interface to a cluster that has
<code>
use_internal_ipv6
</code>
enabled, a
<code>
NodeBootstrapError
</code>
occurs.
</p>
<p>
The host file
<code>
/etc/hosts
</code>
on each node in the cluster must include the following entry:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">::1 localhost
</span></span></code></pre>
</div>
<h2 id="change-internal-ip-address">
Change internal IP address
</h2>
<p>
Before you change an internal IP address, consider the following:
</p>
<ul>
<li>
<p>
Verify the address is valid and bound to an active interface on the node. Failure to do so prevents the node from coming back online and rejoining the cluster.
</p>
</li>
<li>
<p>
Joining a node that only has IPv4 network interfaces to a master node with IPv6 enabled causes a
<code>
NodeBootstrapError
</code>
.
</p>
</li>
<li>
<p>
Joining a node that only has IPv6 network interfaces to a master node that does not have IPv6 enabled causes a
<code>
NodeBootstrapError
</code>
.
</p>
</li>
<li>
<p>
You cannot change the internal address from IPv4 to IPv6 or IPv6 to IPv4 in a running cluster. You can only change the internal address within the same protocol as the cluster.
</p>
</li>
</ul>
<p>
If you need to update the internal IP address in the OS, one option is to remove that node from the cluster, change the IP address, and then add the node back into the cluster.
</p>
<p>
Alternatively, you can use the following steps to update a node's internal IP address without removing it from the cluster:
</p>
<ol>
<li>
<p>
Turn the node into a replica using
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/enslave/">
<code>
rladmin
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> enslave demote_node
</span></span></code></pre>
</div>
</li>
<li>
<p>
Deactivate the
<code>
rlec_supervisor
</code>
service on the node:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">systemctl disable rlec_supervisor
</span></span></code></pre>
</div>
</li>
<li>
<p>
Restart the node.
</p>
</li>
<li>
<p>
Follow the operating system vendor's instructions to change the node's IP address.
</p>
</li>
<li>
<p>
From a different cluster node, use
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/addr/">
<code>
rladmin node addr set
</code>
</a>
to update the first node's IP address:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> addr <span class="nb">set</span> <IP address>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Enable the
<code>
rlec_supervisor
</code>
service on the node:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">systemctl <span class="nb">enable</span> rlec_supervisor
</span></span></code></pre>
</div>
</li>
<li>
<p>
Restart
<code>
rlec_supervisor
</code>
or restart the node.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">systemctl start rlec_supervisor
</span></span></code></pre>
</div>
</li>
<li>
<p>
Verify the node rejoined the cluster:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin status nodes
</span></span></code></pre>
</div>
</li>
</ol>
<p>
Repeat this procedure for other cluster nodes to change their internal IP addresses.
</p>
<h2 id="configure-external-ip-addresses">
Configure external IP addresses
</h2>
<p>
You can configure external addresses that are not bound to an active interface, but are otherwise mapped or configured to route traffic to the node (such as AWS Elastic IPs or a load balancer VIP).
</p>
<p>
You can use
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/external-addr/">
rladmin node external_addr
</a>
to change a node's external IP addresses.
</p>
<p>
Add an external IP address:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> external_addr add <IP address>
</span></span></code></pre>
</div>
<p>
Set one or more external IP addresses:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> external_addr <span class="nb">set</span> <IP address 1> <IP address N>
</span></span></code></pre>
</div>
<p>
Remove an external IP address:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> external_addr remove <IP address>
</span></span></code></pre>
</div>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
While
<a href="/docs/latest/operate/rs/clusters/add-node/">
joining a new node to a
cluster
</a>
during the node bootstrap process,
when prompted to provide an IP of an existing node in the cluster,
if you use the node's IP, provide the node's internal IP address.
</div>
</div>
<h2 id="known-limitations">
Known limitations
</h2>
<ul>
<li>
<p>
Using IPv6 for internal traffic is supported only for new clusters running Redis Enterprise Software version 7.4.2 or later.
</p>
</li>
<li>
<p>
Changing an existing cluster's internal traffic from IPv4 to IPv6 is not supported.
</p>
</li>
<li>
<p>
All nodes must use the same protocol for internal traffic.
</p>
</li>
<li>
<p>
If a Redis Enterprise node's host machine has both IPv4 and IPv6 addresses, internal communication within the node initially uses IPv4 until the bootstrap process finishes.
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/networking/multi-ip-ipv6/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/node/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin node
</h1>
<p class="text-lg -mt-5 mb-10">
Manage nodes.
</p>
<p>
<code>
rladmin node
</code>
commands manage nodes in the cluster.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Command
</th>
<th style="text-align:left">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/addr/">
addr
</a>
</td>
<td style="text-align:left">
Sets a node's internal IP address.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/enslave/">
enslave
</a>
</td>
<td style="text-align:left">
Changes a node's resources to replicas.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/external-addr/">
external_addr
</a>
</td>
<td style="text-align:left">
Configures a node's external IP addresses.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/maintenance-mode/">
maintenance_mode
</a>
</td>
<td style="text-align:left">
Turns quorum-only mode on or off for a node.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/recovery-path/">
recovery_path
</a>
</td>
<td style="text-align:left">
Sets a node's local recovery path.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/remove/">
remove
</a>
</td>
<td style="text-align:left">
Removes a node from the cluster.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/node/snapshot/">
snapshot
</a>
</td>
<td style="text-align:left">
Manages snapshots of the configuration of a node's shards and endpoints.
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/node/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/scoring/.html | <section class="prose w-full py-12">
<h1>
Scoring documents
</h1>
<p class="text-lg -mt-5 mb-10">
Full-text scoring functions
</p>
<p>
When searching, documents are scored based on their relevance to the query. The score is a floating point number between 0.0 and 1.0, where 1.0 is the highest score. The score is returned as part of the search results and can be used to sort the results.
</p>
<p>
Redis Stack comes with a few very basic scoring functions to evaluate document relevance. They are all based on document scores and term frequency. This is regardless of the ability to use
<a href="/docs/latest/develop/interact/search-and-query/advanced-concepts/sorting/">
sortable fields
</a>
. Scoring functions are specified by adding the
<code>
SCORER {scorer_name}
</code>
argument to a search query.
</p>
<p>
If you prefer a custom scoring function, it is possible to add more functions using the
<a href="/docs/latest/develop/interact/search-and-query/administration/extensions/">
extension API
</a>
.
</p>
<p>
The following is a list of the pre-bundled scoring functions available in Redis Stack and a short explanation about how they work. Each function is mentioned by registered name, which can be passed as a
<code>
SCORER
</code>
argument in
<a href="/docs/latest/commands/ft.search/">
<code>
FT.SEARCH
</code>
</a>
.
</p>
<h2 id="tfidf-default">
TFIDF (default)
</h2>
<p>
Basic
<a href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf">
TF-IDF scoring
</a>
with a few extra features:
</p>
<ol>
<li>
<p>
For each term in each result, the TF-IDF score of that term is calculated to that document. Frequencies are weighted based on field weights that are pre-determined, and each term's frequency is normalized by the highest term frequency in each document.
</p>
</li>
<li>
<p>
The total TF-IDF for the query term is multiplied by the presumptive document score given on
<code>
FT.CREATE
</code>
via
<code>
SCORE_FIELD
</code>
.
</p>
</li>
<li>
<p>
A penalty is assigned to each result based on "slop" or cumulative distance between the search terms. Exact matches will get no penalty, but matches where the search terms are distant will have their score reduced significantly. For each bigram of consecutive terms, the minimal distance between them is determined. The penalty is the square root of the sum of the distances squared; e.g.,
<code>
1/sqrt(d(t2-t1)^2 + d(t3-t2)^2 + ...)
</code>
.
</p>
</li>
</ol>
<p>
Given N terms in document D,
<code>
T1...Tn
</code>
, the resulting score could be described with this Python function:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-py" data-lang="py"><span class="line"><span class="cl"><span class="k">def</span> <span class="nf">get_score</span><span class="p">(</span><span class="n">terms</span><span class="p">,</span> <span class="n">doc</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># the sum of tf-idf</span>
</span></span><span class="line"><span class="cl"> <span class="n">score</span> <span class="o">=</span> <span class="mi">0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># the distance penalty for all terms</span>
</span></span><span class="line"><span class="cl"> <span class="n">dist_penalty</span> <span class="o">=</span> <span class="mi">0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">term</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">terms</span><span class="p">):</span>
</span></span><span class="line"><span class="cl"> <span class="c1"># tf normalized by maximum frequency</span>
</span></span><span class="line"><span class="cl"> <span class="n">tf</span> <span class="o">=</span> <span class="n">doc</span><span class="o">.</span><span class="n">freq</span><span class="p">(</span><span class="n">term</span><span class="p">)</span> <span class="o">/</span> <span class="n">doc</span><span class="o">.</span><span class="n">max_freq</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># idf is global for the index, and not calculated each time in real life</span>
</span></span><span class="line"><span class="cl"> <span class="n">idf</span> <span class="o">=</span> <span class="n">log2</span><span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">total_docs</span> <span class="o">/</span> <span class="n">docs_with_term</span><span class="p">(</span><span class="n">term</span><span class="p">))</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">score</span> <span class="o">+=</span> <span class="n">tf</span><span class="o">*</span><span class="n">idf</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># sum up the distance penalty</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="n">i</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">dist_penalty</span> <span class="o">+=</span> <span class="n">min_distance</span><span class="p">(</span><span class="n">term</span><span class="p">,</span> <span class="n">terms</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span><span class="o">**</span><span class="mi">2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># multiply the score by the document score</span>
</span></span><span class="line"><span class="cl"> <span class="n">score</span> <span class="o">*=</span> <span class="n">doc</span><span class="o">.</span><span class="n">score</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1"># divide the score by the root of the cumulative distance</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">terms</span><span class="p">)</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
</span></span><span class="line"><span class="cl"> <span class="n">score</span> <span class="o">/=</span> <span class="n">sqrt</span><span class="p">(</span><span class="n">dist_penalty</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="n">score</span>
</span></span></code></pre>
</div>
<h2 id="tfidfdocnorm">
TFIDF.DOCNORM
</h2>
<p>
Identical to the default
<code>
TFIDF
</code>
scorer, with one important distinction:
</p>
<p>
Term frequencies are normalized by the length of the document, expressed as the total number of terms. The length is weighted, so that if a document contains two terms, one in a field that has a weight 1 and one in a field with a weight of 5, the total frequency is 6, not 2.
</p>
<pre tabindex="0"><code>FT.SEARCH myIndex "foo" SCORER TFIDF.DOCNORM
</code></pre>
<h2 id="bm25">
BM25
</h2>
<p>
A variation on the basic
<code>
TFIDF
</code>
scorer, see
<a href="https://en.wikipedia.org/wiki/Okapi_BM25">
this Wikipedia article for more info
</a>
.
</p>
<p>
The relevance score for each document is multiplied by the presumptive document score and a penalty is applied based on slop as in
<code>
TFIDF
</code>
.
</p>
<pre tabindex="0"><code>FT.SEARCH myIndex "foo" SCORER BM25
</code></pre>
<h2 id="dismax">
DISMAX
</h2>
<p>
A simple scorer that sums up the frequencies of matched terms. In the case of union clauses, it will give the maximum value of those matches. No other penalties or factors are applied.
</p>
<p>
It is not a one-to-one implementation of
<a href="https://wiki.apache.org/solr/DisMax">
Solr's DISMAX algorithm
</a>
, but it follows it in broad terms.
</p>
<pre tabindex="0"><code>FT.SEARCH myIndex "foo" SCORER DISMAX
</code></pre>
<h2 id="docscore">
DOCSCORE
</h2>
<p>
A scoring function that just returns the presumptive score of the document without applying any calculations to it. Since document scores can be updated, this can be useful if you'd like to use an external score and nothing further.
</p>
<pre tabindex="0"><code>FT.SEARCH myIndex "foo" SCORER DOCSCORE
</code></pre>
<h2 id="hamming">
HAMMING
</h2>
<p>
Scoring by the inverse Hamming distance between the document's payload and the query payload is performed. Since the nearest neighbors are of interest, the inverse Hamming distance (
<code>
1/(1+d)
</code>
) is used so that a distance of 0 gives a perfect score of 1 and is the highest rank.
</p>
<p>
This only works if:
</p>
<ol>
<li>
The document has a payload.
</li>
<li>
The query has a payload.
</li>
<li>
Both are exactly the same length.
</li>
</ol>
<p>
Payloads are binary-safe, and having payloads with a length that is a multiple of 64 bits yields slightly faster results.
</p>
<p>
Example:
</p>
<pre tabindex="0"><code>> HSET key:1 foo hello payload aaaabbbb
(integer) 2
> HSET key:2 foo bar payload aaaacccc
(integer) 2
> FT.CREATE idx ON HASH PREFIX 1 key: PAYLOAD_FIELD payload SCHEMA foo TEXT
"OK"
> FT.SEARCH idx "*" PAYLOAD "aaaabbbc" SCORER HAMMING WITHSCORES
1) "2"
2) "key:1"
3) "0.5"
4) 1) "foo"
2) "hello"
5) "key:2"
6) "0.25"
7) 1) "foo"
2) "bar"
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/scoring/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/clients/redis-py/queryjson/.html | <section class="prose w-full py-12">
<h1>
Example - Index and query JSON documents
</h1>
<p class="text-lg -mt-5 mb-10">
Learn how to use the Redis query engine with JSON
</p>
<p>
This example shows how to create a
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
search index
</a>
for
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
data and
run queries against the index.
</p>
<p>
Make sure that you have Redis Stack and
<code>
redis-py
</code>
installed.
</p>
<p>
Import dependencies:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.json.path</span> <span class="kn">import</span> <span class="n">Path</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.commands.search.aggregation</span> <span class="k">as</span> <span class="nn">aggregations</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.commands.search.reducers</span> <span class="k">as</span> <span class="nn">reducers</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.field</span> <span class="kn">import</span> <span class="n">TextField</span><span class="p">,</span> <span class="n">NumericField</span><span class="p">,</span> <span class="n">TagField</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.indexDefinition</span> <span class="kn">import</span> <span class="n">IndexDefinition</span><span class="p">,</span> <span class="n">IndexType</span>
</span></span><span class="line"><span class="cl"><span class="kn">from</span> <span class="nn">redis.commands.search.query</span> <span class="kn">import</span> <span class="n">NumericFilter</span><span class="p">,</span> <span class="n">Query</span>
</span></span></code></pre>
</div>
<p>
Connect to your Redis database.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s1">'localhost'</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">)</span>
</span></span></code></pre>
</div>
<p>
Let's create some test data to add to your database.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">user1</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Paul John"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">42</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"city"</span><span class="p">:</span> <span class="s2">"London"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="n">user2</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Eden Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">29</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"city"</span><span class="p">:</span> <span class="s2">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="n">user3</span> <span class="o">=</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span><span class="p">:</span> <span class="s2">"Paul Zamir"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"age"</span><span class="p">:</span> <span class="mi">35</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"city"</span><span class="p">:</span> <span class="s2">"Tel Aviv"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
Define indexed fields and their data types using
<code>
schema
</code>
. Use JSON path expressions to map specific JSON elements to the schema fields.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">schema</span> <span class="o">=</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">TextField</span><span class="p">(</span><span class="s2">"$.name"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"name"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">TagField</span><span class="p">(</span><span class="s2">"$.city"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"city"</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="n">NumericField</span><span class="p">(</span><span class="s2">"$.age"</span><span class="p">,</span> <span class="n">as_name</span><span class="o">=</span><span class="s2">"age"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<p>
Create an index. In this example, all JSON documents with the key prefix
<code>
user:
</code>
will be indexed. For more information, see
<a href="/docs/latest/develop/interact/search-and-query/query/">
Query syntax
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">rs</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">ft</span><span class="p">(</span><span class="s2">"idx:users"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">rs</span><span class="o">.</span><span class="n">create_index</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">schema</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">definition</span><span class="o">=</span><span class="n">IndexDefinition</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">prefix</span><span class="o">=</span><span class="p">[</span><span class="s2">"user:"</span><span class="p">],</span> <span class="n">index_type</span><span class="o">=</span><span class="n">IndexType</span><span class="o">.</span><span class="n">JSON</span>
</span></span><span class="line"><span class="cl"> <span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># b'OK'</span>
</span></span></code></pre>
</div>
<p>
Use
<a href="/docs/latest/commands/json.set/">
<code>
JSON.SET
</code>
</a>
to set each user value at the specified path.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"user:1"</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">user1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"user:2"</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">user2</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"user:3"</span><span class="p">,</span> <span class="n">Path</span><span class="o">.</span><span class="n">root_path</span><span class="p">(),</span> <span class="n">user3</span><span class="p">)</span>
</span></span></code></pre>
</div>
<p>
Let's find user
<code>
Paul
</code>
and filter the results by age.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">rs</span><span class="o">.</span><span class="n">search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">Query</span><span class="p">(</span><span class="s2">"Paul @age:[30 40]"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># Result{1 total, docs: [Document {'id': 'user:3', 'payload': None, 'json': '{"name":"Paul Zamir","email":"[email protected]","age":35,"city":"Tel Aviv"}'}]}</span>
</span></span></code></pre>
</div>
<p>
Query using JSON Path expressions.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">rs</span><span class="o">.</span><span class="n">search</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">Query</span><span class="p">(</span><span class="s2">"Paul"</span><span class="p">)</span><span class="o">.</span><span class="n">return_field</span><span class="p">(</span><span class="s2">"$.city"</span><span class="p">,</span> <span class="n">as_field</span><span class="o">=</span><span class="s2">"city"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span><span class="o">.</span><span class="n">docs</span>
</span></span><span class="line"><span class="cl"><span class="c1"># [Document {'id': 'user:1', 'payload': None, 'city': 'London'}, Document {'id': 'user:3', 'payload': None, 'city': 'Tel Aviv'}]</span>
</span></span></code></pre>
</div>
<p>
Aggregate your results using
<a href="/docs/latest/commands/ft.aggregate/">
<code>
FT.AGGREGATE
</code>
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">req</span> <span class="o">=</span> <span class="n">aggregations</span><span class="o">.</span><span class="n">AggregateRequest</span><span class="p">(</span><span class="s2">"*"</span><span class="p">)</span><span class="o">.</span><span class="n">group_by</span><span class="p">(</span><span class="s1">'@city'</span><span class="p">,</span> <span class="n">reducers</span><span class="o">.</span><span class="n">count</span><span class="p">()</span><span class="o">.</span><span class="n">alias</span><span class="p">(</span><span class="s1">'count'</span><span class="p">))</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">rs</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">req</span><span class="p">)</span><span class="o">.</span><span class="n">rows</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># [[b'city', b'Tel Aviv', b'count', b'2'], [b'city', b'London', b'count', b'1']]</span>
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/clients/redis-py/queryjson/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin node
</h1>
<p class="text-lg -mt-5 mb-10">
Manage nodes.
</p>
<p>
<code>
rladmin node
</code>
commands manage nodes in the cluster.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
Command
</th>
<th style="text-align:left">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/addr/">
addr
</a>
</td>
<td style="text-align:left">
Sets a node's internal IP address.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/enslave/">
enslave
</a>
</td>
<td style="text-align:left">
Changes a node's resources to replicas.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/external-addr/">
external_addr
</a>
</td>
<td style="text-align:left">
Configures a node's external IP addresses.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/maintenance-mode/">
maintenance_mode
</a>
</td>
<td style="text-align:left">
Turns quorum-only mode on or off for a node.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/recovery-path/">
recovery_path
</a>
</td>
<td style="text-align:left">
Sets a node's local recovery path.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/remove/">
remove
</a>
</td>
<td style="text-align:left">
Removes a node from the cluster.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/snapshot/">
snapshot
</a>
</td>
<td style="text-align:left">
Manages snapshots of the configuration of a node's shards and endpoints.
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/xdel/.html | <section class="prose w-full py-12">
<h1 class="command-name">
XDEL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">XDEL key id [id ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
5.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) for each single item to delete in the stream, regardless of the stream size.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@stream
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Removes the specified entries from a stream, and returns the number of entries
deleted. This number may be less than the number of IDs passed to the command in
the case where some of the specified IDs do not exist in the stream.
</p>
<p>
Normally you may think at a Redis stream as an append-only data structure,
however Redis streams are represented in memory, so we are also able to
delete entries. This may be useful, for instance, in order to comply with
certain privacy policies.
</p>
<h2 id="understanding-the-low-level-details-of-entries-deletion">
Understanding the low level details of entries deletion
</h2>
<p>
Redis streams are represented in a way that makes them memory efficient:
a radix tree is used in order to index macro-nodes that pack linearly tens
of stream entries. Normally what happens when you delete an entry from a stream
is that the entry is not
<em>
really
</em>
evicted, it just gets marked as deleted.
</p>
<p>
Eventually if all the entries in a macro-node are marked as deleted, the whole
node is destroyed and the memory reclaimed. This means that if you delete
a large amount of entries from a stream, for instance more than 50% of the
entries appended to the stream, the memory usage per entry may increment, since
what happens is that the stream will become fragmented. However the stream
performance will remain the same.
</p>
<p>
In future versions of Redis it is possible that we'll trigger a node garbage
collection in case a given macro-node reaches a given amount of deleted
entries. Currently with the usage we anticipate for this data structure, it is
not a good idea to add such complexity.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>> XADD mystream * a 1
1538561698944-0
> XADD mystream * b 2
1538561700640-0
> XADD mystream * c 3
1538561701744-0
> XDEL mystream 1538561700640-0
(integer) 1
127.0.0.1:6379> XRANGE mystream - +
1) 1) 1538561698944-0
2) 1) "a"
2) "1"
2) 1) 1538561701744-0
2) 1) "c"
2) "3"
</code></pre>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of entries that were deleted.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/xdel/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/changelog/2023/september-2023/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud changelog (September 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
New features, enhancements, and other changes added to Redis Cloud during September 2023.
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="resp-protocol-selection">
RESP protocol selection
</h3>
<p>
For all databases using Redis 7.2, you can now choose between the RESP2 and RESP3 protocols when you
<a href="/docs/latest/operate/rc/databases/create-database/">
create a database
</a>
. For more information about the different RESP versions, see the
<a href="/docs/latest/develop/reference/protocol-spec/#resp-versions">
Redis serialization protocol specification
</a>
.
</p>
<h3 id="opt-in-to-redis-72">
Opt-in to Redis 7.2
</h3>
<p>
Select
<strong>
Opt-in to 7.2
</strong>
to request to upgrade your subscription and databases to Redis 7.2 (
<em>
Redis 6.2 and earlier only
</em>
).
</p>
<a href="/docs/latest/images/rc/button-opt-in-to-72.png" sdata-lightbox="/images/rc/button-opt-in-to-72.png">
<img alt="Opt-in to 7.2 button." src="/docs/latest/images/rc/button-opt-in-to-72.png" width="150px"/>
</a>
<p>
The upgrade will start one week from your request, according to
<a href="/docs/latest/operate/rc/subscriptions/maintenance/set-maintenance-windows/">
maintenance windows
</a>
.
</p>
<p>
Redis 7.2 introduces several changes to existing Redis commands; see the list of
<a href="/docs/latest/operate/rc/changelog/2023/june-2023/#redis-72-breaking-changes">
breaking changes
</a>
for more details.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/changelog/2023/september-2023/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/docker-quickstart/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Docker quickstart for Redis Enterprise Software
</h1>
<p class="text-lg -mt-5 mb-10">
Set up a development or test deployment of Redis Enterprise Software using Docker.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
Docker containers are currently only supported for development and test environments, not for production. Use
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise on Kubernetes
</a>
for a supported containerized deployment.
</div>
</div>
<p>
For testing purposes, you can run Redis Enterprise Software on Docker containers on
Linux, Windows, or MacOS.
The
<a href="https://hub.docker.com/r/redislabs/redis/">
Redis Enterprise Software container
</a>
acts as a node in a cluster.
</p>
<p>
To get started with a single Redis Enterprise Software container:
</p>
<ol>
<li>
<p>
<a href="#install-docker">
Install Docker
</a>
for your operating system
</p>
</li>
<li>
<p>
<a href="#run-the-container">
Run the Redis Enterprise Software Docker container
</a>
</p>
</li>
<li>
<p>
<a href="#set-up-a-cluster">
Set up a cluster
</a>
</p>
</li>
<li>
<p>
<a href="#create-a-database">
Create a new database
</a>
</p>
</li>
<li>
<p>
<a href="#connect-to-your-database">
Connect to your database
</a>
</p>
</li>
</ol>
<h2 id="install-docker">
Install Docker
</h2>
<p>
Follow the Docker installation instructions for your operating system:
</p>
<ul>
<li>
<a href="https://docs.docker.com/install/#supported-platforms">
Linux
</a>
</li>
<li>
<a href="https://docs.docker.com/docker-for-mac/install/">
MacOS
</a>
</li>
<li>
<a href="https://store.docker.com/editions/community/docker-ce-desktop-windows">
Windows
</a>
</li>
</ul>
<h2 id="run-the-container">
Run the container
</h2>
<p>
To download and start the Redis Enterprise Software Docker container, run the following
<a href="https://docs.docker.com/engine/reference/commandline/run/">
<code>
docker run
</code>
</a>
command in the terminal or command line for your operating system.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
On Windows, make sure Docker is configured to run Linux-based containers.
</div>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">docker run -d --cap-add sys_resource --name RE -p 8443:8443 -p 9443:9443 -p 12000:12000 redislabs/redis
</span></span></code></pre>
</div>
<p>
The example command runs the Docker container with Redis Enterprise Software on
<code>
localhost
</code>
and opens the following ports:
</p>
<ul>
<li>
<p>
Port 8443 for HTTPS connections
</p>
</li>
<li>
<p>
Port 9443 for
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
connections
</p>
</li>
<li>
<p>
Port 12000 configured Redis database port allowing client connections
</p>
</li>
</ul>
<p>
You can publish other
<a href="/docs/latest/operate/rs/7.4/networking/port-configurations/">
ports
</a>
with
<code>
-p <host_port>:<container_port>
</code>
or use the
<code>
--network host
</code>
option to open all ports to the host network.
</p>
<h2 id="set-up-a-cluster">
Set up a cluster
</h2>
<ol>
<li>
<p>
In the web browser on the host machine, go to
<a href="https://localhost:8443">
https://localhost:8443
</a>
to see
the new Redis Enterprise Software Cluster Manager UI. The cluster generates self-signed TLS certificates to secure the connection. These self-signed certificates are unknown to the browser and must be accepted before you proceed.
</p>
<p>
To use the legacy UI for this quickstart instead, see the
<a href="https://docs.redis.com/6.4/rs/installing-upgrading/quickstarts/">
6.4 version of the quickstarts
</a>
.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<ul>
<li>
If the server does not show the login screen, try again after a few minutes.
</li>
</ul>
</div>
</div>
</li>
<li>
<p>
Select
<strong>
Create new cluster
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/create-cluster.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/create-cluster.png">
<img alt="When you first install Redis Enterprise Software, you need to set up a cluster." src="/docs/latest/images/rs/screenshots/cluster/setup/create-cluster.png"/>
</a>
</li>
<li>
<p>
Enter an email and password for the administrator account, then select
<strong>
Next
</strong>
to proceed to cluster setup.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/admin-credentials.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/admin-credentials.png">
<img alt="Set the credentials for your admin user." src="/docs/latest/images/rs/screenshots/cluster/setup/admin-credentials.png"/>
</a>
<p>
You can also use these credentials to connect to the
<a href="/docs/latest/operate/rs/7.4/references/rest-api/">
REST API
</a>
.
</p>
</li>
<li>
<p>
Enter your cluster license key if you have one. Otherwise, a trial version is installed.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/cluster-license-key.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/cluster-license-key.png">
<img alt="Enter your cluster license key if you have one." src="/docs/latest/images/rs/screenshots/cluster/setup/cluster-license-key.png"/>
</a>
</li>
<li>
<p>
In the
<strong>
Configuration
</strong>
section, enter a cluster FQDN such as
<code>
cluster.local
</code>
, then select
<strong>
Next
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/config-cluster.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/config-cluster.png">
<img alt="Configure the cluster FQDN." src="/docs/latest/images/rs/screenshots/cluster/setup/config-cluster.png"/>
</a>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
If the FQDN is
<code>
cluster.local
</code>
, you cannot configure DNS. You cannot change the FQDN after cluster creation.
</div>
</div>
</li>
<li>
<p>
On the node setup screen, select
<strong>
Create cluster
</strong>
to accept the defaults.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/node-settings.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/node-settings.png">
<img alt="Configure the node specific settings." src="/docs/latest/images/rs/screenshots/cluster/setup/node-settings.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
OK
</strong>
to acknowledge the replacement of the HTTPS TLS certificate on the node. If you receive a browser warning, you can proceed safely.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png" sdata-lightbox="/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png">
<img alt="Modal shown when a page refresh is needed because the certificates have been updated." src="/docs/latest/images/rs/screenshots/cluster/setup/https-page-refresh-modal.png"/>
</a>
</li>
</ol>
<h2 id="create-a-database">
Create a database
</h2>
<ol>
<li>
<p>
On the
<strong>
Databases
</strong>
screen, select
<strong>
Quick database
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/db-screen.png" sdata-lightbox="/images/rs/screenshots/databases/db-screen.png">
<img alt="Select Quick database on the Databases screen." src="/docs/latest/images/rs/screenshots/databases/db-screen.png"/>
</a>
</li>
<li>
<p>
Enter 12000 for the
<strong>
Port
</strong>
.
</p>
<p>
If port 12000 is not available, enter any available port number between 10000 to 19999 or leave it blank to let the cluster assign a port number for you. You will use this port number to connect to the database.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/quick-db.png" sdata-lightbox="/images/rs/screenshots/databases/quick-db.png">
<img alt="Create a quick database." src="/docs/latest/images/rs/screenshots/databases/quick-db.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
Create
</strong>
to create your database.
</p>
</li>
</ol>
<p>
When you see
<strong>
Database active
</strong>
appear on the database configuration screen, the database is activated and ready for you to use.
</p>
<a href="/docs/latest/images/rs/icons/db-active-icon.png" sdata-lightbox="/images/rs/icons/db-active-icon.png">
<img alt="Database active icon." src="/docs/latest/images/rs/icons/db-active-icon.png" width="150px"/>
</a>
<p>
You now have a Redis database!
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
If you cannot activate the database because of a memory limitation,
make sure that Docker has at least 4 GB of memory allocated in the
<strong>
Advanced
</strong>
section of Docker
<strong>
Settings
</strong>
.
</div>
</div>
<h2 id="connect-to-your-database">
Connect to your database
</h2>
<p>
After you create the Redis database, you can connect to it to begin storing data.
</p>
<h3 id="connect-inside-docker">
Use redis-cli inside Docker
</h3>
<p>
Every installation of Redis Enterprise Software includes the command-line tool
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/redis-cli/">
<code>
redis-cli
</code>
</a>
to interact with your Redis database. You can use
<code>
redis-cli
</code>
to connect to your database from within the same Docker network.
</p>
<p>
Use
<a href="https://docs.docker.com/engine/reference/commandline/exec/">
<code>
docker exec
</code>
</a>
to start an interactive
<code>
redis-cli
</code>
session in the running Redis Enterprise Software container:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ docker <span class="nb">exec</span> -it redis-cli -h redis-12000.cluster.local -p <span class="m">12000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:12000> SET key1 <span class="m">123</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:12000> GET key1
</span></span><span class="line"><span class="cl"><span class="s2">"123"</span>
</span></span></code></pre>
</div>
<h3 id="connect-outside-docker">
Connect from the host environment
</h3>
<p>
The database you created uses port
<code>
12000
</code>
, which is also mapped from the Docker container back to the host environment. This lets you use any method you have available locally to
<a href="/docs/latest/operate/rs/7.4/databases/connect/">
connect to a Redis database
</a>
. Use
<code>
localhost
</code>
as the
<code>
host
</code>
and
<code>
12000
</code>
as the port.
</p>
<h2 id="test-different-topologies">
Test different topologies
</h2>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
Docker containers are currently only supported for development and test environments, not for production. Use
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise on Kubernetes
</a>
for a supported containerized deployment.
</div>
</div>
<p>
When deploying Redis Enterprise Software using Docker for testing, several common topologies are available, according to your requirements:
</p>
<ul>
<li>
<p>
<a href="#single-node">
Single-node cluster
</a>
β For local development or functional testing
</p>
</li>
<li>
<p>
<a href="#multi-node-one-host">
Multi-node cluster on a single host
</a>
β For a small-scale deployment that is similar to production
</p>
</li>
<li>
<p>
<a href="#multi-node-multi-host">
Multi-node cluster with multiple hosts
</a>
β For more predictable performance or high availability compared to single-host deployments
</p>
</li>
</ul>
<h3 id="single-node">
Single node
</h3>
<p>
The simplest topology is to run a single-node Redis Enterprise Software cluster with a single container on a single host machine. You can use this topology for local development or functional testing.
</p>
<p>
Single-node clusters have limited functionality. For example, Redis Enterprise Software can't use replication or protect against failures if the cluster has only one node.
</p>
<a href="/docs/latest/images/rs/RS-Docker-container.png" sdata-lightbox="/images/rs/RS-Docker-container.png">
<img src="/docs/latest/images/rs/RS-Docker-container.png"/>
</a>
<h3 id="multi-node-one-host">
Multiple nodes on one host
</h3>
<p>
You can create a multi-node Redis Enterprise Software cluster by deploying multiple containers to a single host machine. The resulting cluster is scale minimized but similar to production deployments.
</p>
<p>
However, this will also have several limitations. For example, you cannot map the same port on multiple containers on the same host.
</p>
<a href="/docs/latest/images/rs/RS-Docker-cluster-single-host.png" sdata-lightbox="/images/rs/RS-Docker-cluster-single-host.png">
<img src="/docs/latest/images/rs/RS-Docker-cluster-single-host.png"/>
</a>
<h3 id="multi-node-multi-host">
Multiple nodes and hosts
</h3>
<p>
You can create a multi-node Redis Enterprise Software cluster with multiple containers by deploying each container to a different host machine.
</p>
<p>
This topology minimizes interference between containers, allowing for the testing of more Redis Enterprise Software features.
</p>
<a href="/docs/latest/images/rs/RS-Docker-cluster-multi-host.png" sdata-lightbox="/images/rs/RS-Docker-cluster-multi-host.png">
<img src="/docs/latest/images/rs/RS-Docker-cluster-multi-host.png"/>
</a>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/installing-upgrading/quickstarts/docker-quickstart/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/nodes/alerts/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Node alerts requests
</h1>
<p class="text-lg -mt-5 mb-10">
Node alert requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-nodes-alerts">
GET
</a>
</td>
<td>
<code>
/v1/nodes/alerts
</code>
</td>
<td>
Get all alert states for all nodes
</td>
</tr>
<tr>
<td>
<a href="#get-node-alerts">
GET
</a>
</td>
<td>
<code>
/v1/nodes/alerts/{uid}
</code>
</td>
<td>
Get all alert states for a node
</td>
</tr>
<tr>
<td>
<a href="#get-node-alert">
GET
</a>
</td>
<td>
<code>
/v1/nodes/alerts/{uid}/{alert}
</code>
</td>
<td>
Get node alert state
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-nodes-alerts">
Get all alert states
</h2>
<pre><code>GET /v1/nodes/alerts
</code></pre>
<p>
Get all alert states for all nodes.
</p>
<h4 id="required-permissions">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_all_nodes_alerts">
view_all_nodes_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /nodes/alerts
</code></pre>
<h4 id="request-headers">
Request headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Host
</td>
<td>
cnm.cluster.fqdn
</td>
<td>
Domain name
</td>
</tr>
<tr>
<td>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
ignore_settings
</td>
<td>
boolean
</td>
<td>
Retrieve updated alert state regardless of the cluster's alert_settings. When not present, a disabled alert will always be retrieved as disabled with a false state. (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-response">
Response
</h3>
<p>
Returns a hash of node UIDs and the
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert states
</a>
for each node.
</p>
<h4 id="example-json-body">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"1"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"node_cpu_utilization"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-12-22T10:42:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_util"</span><span class="p">:</span> <span class="mf">2.500000000145519</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"global_threshold"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"enabled"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-all-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error
</td>
</tr>
</tbody>
</table>
<h2 id="get-node-alerts">
Get node alert states
</h2>
<pre><code>GET /v1/nodes/alerts/{int: uid}
</code></pre>
<p>
Get all alert states for a node.
</p>
<h4 id="required-permissions-1">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_node_alerts">
view_node_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request-all-alerts">
Request
</h3>
<h4 id="example-http-request-1">
Example HTTP request
</h4>
<pre><code>GET /nodes/alerts/1
</code></pre>
<h4 id="request-headers-1">
Request headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Host
</td>
<td>
cnm.cluster.fqdn
</td>
<td>
Domain name
</td>
</tr>
<tr>
<td>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-1">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
ignore_settings
</td>
<td>
boolean
</td>
<td>
Retrieve updated alert state regardless of the cluster's alert_settings. When not present, a disabled alert will always be retrieved as disabled with a false state. (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-response-all-alerts">
Response
</h3>
<p>
Returns a hash of
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert objects
</a>
and their states for a specific node.
</p>
<h4 id="example-json-body-1">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"node_cpu_utilization"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-12-22T10:42:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_util"</span><span class="p">:</span> <span class="mf">2.500000000145519</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"global_threshold"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"enabled"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"..."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes-all-alerts">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Specified node does not exist
</td>
</tr>
</tbody>
</table>
<h2 id="get-node-alert">
Get node alert state
</h2>
<pre><code>GET /v1/nodes/alerts/{int: uid}/{alert}
</code></pre>
<p>
Get a node alert state.
</p>
<h4 id="required-permissions-2">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_node_alerts">
view_node_alerts
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request-2">
Example HTTP request
</h4>
<pre><code>GET /nodes/alerts/1/node_cpu_utilization
</code></pre>
<h4 id="request-headers-2">
Request headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Host
</td>
<td>
cnm.cluster.fqdn
</td>
<td>
Domain name
</td>
</tr>
<tr>
<td>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters-2">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
ignore_settings
</td>
<td>
boolean
</td>
<td>
Retrieve updated alert state regardless of the cluster's alert_settings. When not present, a disabled alert will always be retrieved as disabled with a false state. (optional)
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns an
<a href="/docs/latest/operate/rs/references/rest-api/objects/alert/">
alert object
</a>
.
</p>
<h4 id="example-json-body-2">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_time"</span><span class="p">:</span> <span class="s2">"2014-12-22T10:42:00Z"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"change_value"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cpu_util"</span><span class="p">:</span> <span class="mf">2.500000000145519</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"global_threshold"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"enabled"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"state"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"severity"</span><span class="p">:</span> <span class="s2">"WARNING"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Specified alert or node does not exist
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/nodes/alerts/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-110/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software release notes 6.4.2-110 (May 2024)
</h1>
<p class="text-lg -mt-5 mb-10">
RedisGraph v2.10.15. RedisBloom v2.4.8. Bug fixes.
</p>
<p>
This is a maintenance release for β
<a href="https://redis.com/redis-enterprise-software/download-center/software/">
βRedis Enterprise Software version 6.4.2
</a>
.
</p>
<h2 id="highlights">
Highlights
</h2>
<p>
This version offers:
</p>
<ul>
<li>
<p>
RedisGraph v2.10.15
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Redis has announced the end of life for RedisGraph. See the
<a href="https://redis.io/blog/redisgraph-eol/">
announcement
</a>
for details.
</div>
</div>
</li>
<li>
<p>
RedisBloom v2.4.8
</p>
</li>
<li>
<p>
Bug fixes
</p>
</li>
</ul>
<h2 id="new-in-this-release">
New in this release
</h2>
<h3 id="enhancements">
Enhancements
</h3>
<h4 id="redis-modules">
Redis modules
</h4>
<p>
Redis Enterprise Software version 6.4.2-110 includes the following Redis Stack modules:
</p>
<ul>
<li>
<p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisearch/redisearch-2.6-release-notes">
RediSearch v2.6.12
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisjson/redisjson-2.4-release-notes">
RedisJSON v2.4.7
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisbloom/redisbloom-2.4-release-notes">
RedisBloom v2.4.8
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redisgraph/redisgraph-2.10-release-notes">
RedisGraph v2.10.15
</a>
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/redistimeseries/redistimeseries-1.8-release-notes">
RedisTimeSeries v1.8.11
</a>
</p>
</li>
</ul>
<h3 id="resolved-issues">
Resolved issues
</h3>
<ul>
<li>
RS123237: CRDT syncer prevents potential data mismatches or data loss due to missing keys when removing and re-adding a cluster in an Active-Active setup with at least three participating clusters after removing older clusters without re-adding them.
</li>
</ul>
<h2 id="version-changes">
Version changes
</h2>
<h3 id="supported-platforms">
Supported platforms
</h3>
<p>
The following table provides a snapshot of supported platforms as of this Redis Enterprise Software release. See the
<a href="/docs/latest/operate/rs/references/supported-platforms/">
supported platforms reference
</a>
for more details about operating system compatibility.
</p>
<p>
<span title="Check mark icon">
β
</span>
Supported β The platform is supported for this version of Redis Enterprise Software and Redis Stack modules.
</p>
<p>
<span class="font-serif" title="Warning icon">
β οΈ
</span>
Deprecation warning β The platform is still supported for this version of Redis Enterprise Software, but support will be removed in a future release.
</p>
<table>
<thead>
<tr>
<th>
Redis Enterprise
<br/>
major versions
</th>
<th style="text-align:center">
7.4
</th>
<th style="text-align:center">
7.2
</th>
<th style="text-align:center">
6.4
</th>
<th style="text-align:center">
6.2
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>
Release date
</strong>
</td>
<td style="text-align:center">
Feb 2024
</td>
<td style="text-align:center">
Aug 2023
</td>
<td style="text-align:center">
Feb 2023
</td>
<td style="text-align:center">
Aug 2021
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/#endoflife-schedule">
<strong>
End-of-life date
</strong>
</a>
</td>
<td style="text-align:center">
Determined after
<br/>
next major release
</td>
<td style="text-align:center">
July 2025
</td>
<td style="text-align:center">
Feb 2025
</td>
<td style="text-align:center">
Aug 2024
</td>
</tr>
<tr>
<td>
<strong>
Platforms
</strong>
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td>
RHEL 9 &
<br/>
compatible distros
<sup>
<a href="#table-note-1">
1
</a>
</sup>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
</tr>
<tr>
<td>
RHEL 8 &
<br/>
compatible distros
<sup>
<a href="#table-note-1">
1
</a>
</sup>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
RHEL 7 &
<br/>
compatible distros
<sup>
<a href="#table-note-1">
1
</a>
</sup>
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span class="font-serif" title="Deprecated">
β οΈ
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Ubuntu 20.04
<sup>
<a href="#table-note-2">
2
</a>
</sup>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
β
</td>
</tr>
<tr>
<td>
Ubuntu 18.04
<sup>
<a href="#table-note-2">
2
</a>
</sup>
</td>
<td style="text-align:center">
<span class="font-serif" title="Deprecated">
β οΈ
</span>
</td>
<td style="text-align:center">
<span class="font-serif" title="Deprecated">
β οΈ
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Ubuntu 16.04
<sup>
<a href="#table-note-2">
2
</a>
</sup>
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span class="font-serif" title="Deprecated">
β οΈ
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Amazon Linux 2
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
β
</td>
</tr>
<tr>
<td>
Amazon Linux 1
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Kubernetes
<sup>
<a href="#table-note-3">
3
</a>
</sup>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td>
Docker
<sup>
<a href="#table-note-4">
4
</a>
</sup>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
</tbody>
</table>
<ol>
<li>
<p>
<a name="table-note-1" style="display: block; height: 80px; margin-top: -80px;">
</a>
The RHEL-compatible distributions CentOS, CentOS Stream, Alma, and Rocky are supported if they have full RHEL compatibility. Oracle Linux running the Red Hat Compatible Kernel (RHCK) is supported, but the Unbreakable Enterprise Kernel (UEK) is not supported.
</p>
</li>
<li>
<p>
<a name="table-note-2" style="display: block; height: 80px; margin-top: -80px;">
</a>
The server version of Ubuntu is recommended for production installations. The desktop version is only recommended for development deployments.
</p>
</li>
<li>
<p>
<a name="table-note-3" style="display: block; height: 80px; margin-top: -80px;">
</a>
See the
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Redis Enterprise for Kubernetes documentation
</a>
for details about support per version and Kubernetes distribution.
</p>
</li>
<li>
<p>
<a name="table-note-4" style="display: block; height: 80px; margin-top: -80px;">
</a>
<a href="/docs/latest/operate/rs/installing-upgrading/quickstarts/docker-quickstart/">
Docker images
</a>
of Redis Enterprise Software are certified for development and testing only.
</p>
</li>
</ol>
<h2 id="downloads">
Downloads
</h2>
<p>
The following table shows the MD5 checksums for the available packages:
</p>
<table>
<thead>
<tr>
<th>
Package
</th>
<th>
MD5 checksum (6.4.2-110 May release)
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Ubuntu 16
</td>
<td>
e61aab4bbb6837230451b70f8e0aa056
</td>
</tr>
<tr>
<td>
Ubuntu 18
</td>
<td>
3180ea41e744acca860257dcef6c49c4
</td>
</tr>
<tr>
<td>
Red Hat Enterprise Linux (RHEL) 7
</td>
<td>
aaf0c1110f5ecc9ce55bf2935f2bcb73
</td>
</tr>
<tr>
<td>
Red Hat Enterprise Linux (RHEL) 8
</td>
<td>
d69894c4bc0860274973a4d78d53cb5d
</td>
</tr>
<tr>
<td>
Amazon Linux 2
</td>
<td>
19ac38908e47bd59c5890d1fc3bdba17
</td>
</tr>
</tbody>
</table>
<h2 id="security">
Security
</h2>
<h4 id="open-source-redis-security-fixes-compatibility">
Open source Redis security fixes compatibility
</h4>
<p>
As part of Redis's commitment to security, Redis Enterprise Software implements the latest
<a href="https://github.com/redis/redis/releases">
security fixes
</a>
available with
<a href="https://github.com/redis/redis">
open source Redis
</a>
. Redis Enterprise has already included the fixes for the relevant CVEs.
</p>
<p>
Some CVEs announced for open source Redis do not affect Redis Enterprise due to different or additional functionality available in Redis Enterprise that is not available in open source Redis.
</p>
<p>
Redis Enterprise 6.4.2-110 supports open source Redis 6.2 and 6.0. Below is the list of open source Redis CVEs fixed by version.
</p>
<p>
Redis 6.2.x:
</p>
<ul>
<li>
<p>
(CVE-2024-31449) An authenticated user may use a specially crafted Lua script to trigger a stack buffer overflow in the bit library, which may potentially lead to remote code execution.
</p>
</li>
<li>
<p>
(CVE-2024-31228) An authenticated user can trigger a denial-of-service by using specially crafted, long string match patterns on supported commands such as
<code>
KEYS
</code>
,
<code>
SCAN
</code>
,
<code>
PSUBSCRIBE
</code>
,
<code>
FUNCTION LIST
</code>
,
<code>
COMMAND LIST
</code>
, and ACL definitions. Matching of extremely long patterns may result in unbounded recursion, leading to stack overflow and process crashes.
</p>
</li>
<li>
<p>
(CVE-2023-45145) The wrong order of listen(2) and chmod(2) calls creates a
race condition that can be used by another process to bypass desired Unix
socket permissions on startup. (Redis 6.2.14)
</p>
</li>
<li>
<p>
(CVE-2023-28856) Authenticated users can use the
<code>
HINCRBYFLOAT
</code>
command to create an invalid hash field that will crash Redis on access. (Redis 6.2.12)
</p>
</li>
<li>
<p>
(CVE-2023-25155) Specially crafted
<code>
SRANDMEMBER
</code>
,
<code>
ZRANDMEMBER
</code>
, and
<code>
HRANDFIELD
</code>
commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.2.11)
</p>
</li>
<li>
<p>
(CVE-2023-22458) Integer overflow in the Redis
<code>
HRANDFIELD
</code>
and
<code>
ZRANDMEMBER
</code>
commands can lead to denial-of-service. (Redis 6.2.9)
</p>
</li>
<li>
<p>
(CVE-2022-36021) String matching commands (like
<code>
SCAN
</code>
or
<code>
KEYS
</code>
) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.2.11)
</p>
</li>
<li>
<p>
(CVE-2022-35977) Integer overflow in the Redis
<code>
SETRANGE
</code>
and
<code>
SORT
</code>
/
<code>
SORT_RO
</code>
commands can drive Redis to OOM panic. (Redis 6.2.9)
</p>
</li>
<li>
<p>
(CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.2.13)
</p>
</li>
<li>
<p>
(CVE-2022-24736) An attacker attempting to load a specially crafted Lua script can cause NULL pointer dereference which will result in a crash of the
<code>
redis-server
</code>
process. This issue affects all versions of Redis. (Redis 6.2.7)
</p>
</li>
<li>
<p>
(CVE-2022-24735) By exploiting weaknesses in the Lua script execution environment, an attacker with access to Redis can inject Lua code that will execute with the (potentially higher) privileges of another Redis user. (Redis 6.2.7)
</p>
</li>
<li>
<p>
(CVE-2021-41099) Integer to heap buffer overflow handling certain string commands and network payloads, when
<code>
proto-max-bulk-len
</code>
is manually configured to a non-default, very large value. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32762) Integer to heap buffer overflow issue in
<code>
redis-cli
</code>
and
<code>
redis-sentinel
</code>
parsing large multi-bulk replies on some older and less common platforms. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32761) An integer overflow bug in Redis version 2.2 or newer can be exploited using the
<code>
BITFIELD
</code>
command to corrupt the heap and potentially result with remote code execution. (Redis 6.2.5)
</p>
</li>
<li>
<p>
(CVE-2021-32687) Integer to heap buffer overflow with intsets, when
<code>
set-max-intset-entries
</code>
is manually configured to a non-default, very large value. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32675) Denial Of Service when processing RESP request payloads with a large number of elements on many connections. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32672) Random heap reading issue with Lua Debugger. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32628) Integer to heap buffer overflow handling ziplist-encoded data types, when configuring a large, non-default value for
<code>
hash-max-ziplist-entries
</code>
,
<code>
hash-max-ziplist-value
</code>
,
<code>
zset-max-ziplist-entries
</code>
or
<code>
zset-max-ziplist-value
</code>
. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32627) Integer to heap buffer overflow issue with streams, when configuring a non-default, large value for
<code>
proto-max-bulk-len
</code>
and
<code>
client-query-buffer-limit
</code>
. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32626) Specially crafted Lua scripts may result with Heap buffer overflow. (Redis 6.2.6)
</p>
</li>
<li>
<p>
(CVE-2021-32625) An integer overflow bug in Redis version 6.0 or newer can be exploited using the STRALGO LCS command to corrupt the heap and potentially result with remote code execution. This is a result of an incomplete fix by CVE-2021-29477. (Redis 6.2.4)
</p>
</li>
<li>
<p>
(CVE-2021-29478) An integer overflow bug in Redis 6.2 could be exploited to corrupt the heap and potentially result with remote code execution. The vulnerability involves changing the default set-max-intset-entries configuration value, creating a large set key that consists of integer values and using the COPY command to duplicate it. The integer overflow bug exists in all versions of Redis starting with 2.6, where it could result with a corrupted RDB or DUMP payload, but not exploited through COPY (which did not exist before 6.2). (Redis 6.2.3)
</p>
</li>
<li>
<p>
(CVE-2021-29477) An integer overflow bug in Redis version 6.0 or newer could be exploited using the STRALGO LCS command to corrupt the heap and potentially result in remote code execution. The integer overflow bug exists in all versions of Redis starting with 6.0. (Redis 6.2.3)
</p>
</li>
</ul>
<p>
Redis 6.0.x:
</p>
<ul>
<li>
<p>
(CVE-2022-24834) A specially crafted Lua script executing in Redis can trigger a heap overflow in the cjson and cmsgpack libraries, and result in heap corruption and potentially remote code execution. The problem exists in all versions of Redis with Lua scripting support, starting from 2.6, and affects only authenticated and authorized users. (Redis 6.0.20)
</p>
</li>
<li>
<p>
(CVE-2023-28856) Authenticated users can use the
<code>
HINCRBYFLOAT
</code>
command to create an invalid hash field that will crash Redis on access. (Redis 6.0.19)
</p>
</li>
<li>
<p>
(CVE-2023-25155) Specially crafted
<code>
SRANDMEMBER
</code>
,
<code>
ZRANDMEMBER
</code>
, and
<code>
HRANDFIELD
</code>
commands can trigger an integer overflow, resulting in a runtime assertion and termination of the Redis server process. (Redis 6.0.18)
</p>
</li>
<li>
<p>
(CVE-2022-36021) String matching commands (like
<code>
SCAN
</code>
or
<code>
KEYS
</code>
) with a specially crafted pattern to trigger a denial-of-service attack on Redis, causing it to hang and consume 100% CPU time. (Redis 6.0.18)
</p>
</li>
<li>
<p>
(CVE-2022-35977) Integer overflow in the Redis
<code>
SETRANGE
</code>
and
<code>
SORT
</code>
/
<code>
SORT_RO
</code>
commands can drive Redis to OOM panic. (Redis 6.0.17)
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-110/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/security/certificates/updating-certificates/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Update certificates
</h1>
<p class="text-lg -mt-5 mb-10">
Update certificates in a Redis Enterprise cluster.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
When you update the certificates, the new certificate replaces the same certificates on all nodes in the cluster.
</div>
</div>
<h2 id="how-to-update-certificates">
How to update certificates
</h2>
<p>
You can use the
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/">
<code>
rladmin
</code>
</a>
command-line interface (CLI) or the
<a href="/docs/latest/operate/rs/references/rest-api/">
REST API
</a>
to update certificates. The Cluster Manager UI lets you update proxy and syncer certificates on the
<strong>
Cluster > Security > Certificates
</strong>
screen.
</p>
<p>
The new certificates are used the next time the clients connect to the database.
</p>
<p>
When you upgrade Redis Enterprise Software, the upgrade process copies the certificates that are on the first upgraded node to all of the nodes in the cluster.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Don't manually overwrite the files located in
<code>
/etc/opt/redislabs
</code>
. Instead, upload new certificates to a temporary location on one of the cluster nodes, such as the
<code>
/tmp
</code>
directory.
</div>
</div>
<h3 id="use-the-cluster-manager-ui">
Use the Cluster Manager UI
</h3>
<p>
To replace proxy or syncer certificates using the Cluster Manager UI:
</p>
<ol>
<li>
<p>
Go to
<strong>
Cluster > Security > Certificates
</strong>
.
</p>
</li>
<li>
<p>
Expand the section for the certificate you want to update:
</p>
<ul>
<li>
For the proxy certificate, expand
<strong>
Server authentication
</strong>
.
</li>
<li>
For the syncer certificate, expand
<strong>
Replica Of and Active-Active authentication
</strong>
.
</li>
</ul>
<a href="/docs/latest/images/rs/screenshots/cluster/security-expand-proxy-cert.png" sdata-lightbox="/images/rs/screenshots/cluster/security-expand-proxy-cert.png">
<img alt="Expanded proxy certificate for server authentication." src="/docs/latest/images/rs/screenshots/cluster/security-expand-proxy-cert.png"/>
</a>
</li>
<li>
<p>
Click
<strong>
Replace Certificate
</strong>
to open the dialog.
</p>
<a href="/docs/latest/images/rs/screenshots/cluster/security-replace-proxy-cert.png" sdata-lightbox="/images/rs/screenshots/cluster/security-replace-proxy-cert.png">
<img alt="Replace proxy certificate dialog." src="/docs/latest/images/rs/screenshots/cluster/security-replace-proxy-cert.png"/>
</a>
</li>
<li>
<p>
Upload the key file.
</p>
</li>
<li>
<p>
Upload the new certificate.
</p>
</li>
<li>
<p>
Click
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h3 id="use-the-cli">
Use the CLI
</h3>
<p>
To replace certificates with the
<code>
rladmin
</code>
CLI, run the
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/cluster/certificate/">
<code>
cluster certificate set
</code>
</a>
command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"> rladmin cluster certificate <span class="nb">set</span> <cert-name> certificate_file <cert-file-name>.pem key_file <key-file-name>.pem
</span></span></code></pre>
</div>
<p>
Replace the following variables with your own values:
</p>
<ul>
<li>
<code>
<cert-name>
</code>
- The name of the certificate you want to replace. See the
<a href="/docs/latest/operate/rs/security/certificates/">
certificates table
</a>
for the list of valid certificate names.
</li>
<li>
<code>
<cert-file-name>
</code>
- The name of your certificate file
</li>
<li>
<code>
<key-file-name>
</code>
- The name of your key file
</li>
</ul>
<p>
For example, to replace the Cluster Manager UI (
<code>
cm
</code>
) certificate with the private key
<code>
key.pem
</code>
and the certificate file
<code>
cluster.pem
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin cluster certificate <span class="nb">set</span> cm certificate_file cluster.pem key_file key.pem
</span></span></code></pre>
</div>
<h3 id="use-the-rest-api">
Use the REST API
</h3>
<p>
To replace a certificate using the REST API, use
<a href="/docs/latest/operate/rs/references/rest-api/requests/cluster/certificates/#put-cluster-update_cert">
<code>
PUT /v1/cluster/update_cert
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">PUT https://<span class="o">[</span>host<span class="o">][</span>:port<span class="o">]</span>/v1/cluster/update_cert
</span></span><span class="line"><span class="cl"> <span class="s1">'{ "name": "<cert_name>", "key": "<key>", "certificate": "<cert>" }'</span>
</span></span></code></pre>
</div>
<p>
Replace the following variables with your own values:
</p>
<ul>
<li>
<p>
<code>
<cert_name>
</code>
- The name of the certificate to replace. See the
<a href="/docs/latest/operate/rs/security/certificates/">
certificates table
</a>
for the list of valid certificate names.
</p>
</li>
<li>
<p>
<code>
<key>
</code>
- The contents of the *_key.pem file
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Tip:
</div>
The key file contains
<code>
\n
</code>
end of line characters (EOL) that you cannot paste into the API call.
You can use
<code>
sed -z 's/\n/\\\n/g'
</code>
to escape the EOL characters.
</div>
</div>
</li>
<li>
<p>
<code>
<cert>
</code>
- The contents of the *_cert.pem file
</p>
</li>
</ul>
<h2 id="replica-of-database-certificates">
Replica Of database certificates
</h2>
<p>
This section describes how to update certificates for Replica Of databases.
</p>
<h3 id="update-ap-proxy-certs">
Update proxy certificates
</h3>
<p>
To update the proxy certificate on clusters running Replica Of databases:
</p>
<ol>
<li>
<p>
Use the Cluster Manager UI,
<code>
rladmin
</code>
, or the REST API to update the proxy certificate on the source database cluster.
</p>
</li>
<li>
<p>
From the Cluster Manager UI, update the destination database (
<em>
replica
</em>
) configuration with the
<a href="/docs/latest/operate/rs/databases/import-export/replica-of/create/#encrypt-replica-database-traffic">
new certificate
</a>
.
</p>
</li>
</ol>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<ul>
<li>
Perform step 2 as quickly as possible after performing step 1. Connections using the previous certificate are rejected after applying the new certificate. Until both steps are performed, recovery of the database sync cannot be established.
</li>
</ul>
</div>
</div>
<h2 id="active-active-database-certificates">
Active-Active database certificates
</h2>
<h3 id="update-aa-proxy-certs">
Update proxy certificates
</h3>
<p>
To update proxy certificate on clusters running Active-Active databases:
</p>
<ol>
<li>
<p>
Use the Cluster Manager UI,
<code>
rladmin
</code>
, or the REST API to update proxy certificates on a single cluster, multiple clusters, or all participating clusters.
</p>
</li>
<li>
<p>
Use the
<a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/">
<code>
crdb-cli
</code>
</a>
utility to update Active-Active database configuration from the command line. Run the following command once for each Active-Active database residing on the modified clusters:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid <CRDB-GUID> --force
</span></span></code></pre>
</div>
</li>
</ol>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<ul>
<li>
Perform step 2 as quickly as possible after performing step 1. Connections using the previous certificate are rejected after applying the new certificate. Until both steps are performed, recovery of the database sync cannot be established.
<br/>
</li>
<li>
Do not run any other
<code>
crdb-cli crdb update
</code>
operations between the two steps.
</li>
</ul>
</div>
</div>
<h3 id="update-aa-syncer-certs">
Update syncer certificates
</h3>
<p>
To update your syncer certificate on clusters running Active-Active databases, follow these steps:
</p>
<ol>
<li>
<p>
Update your syncer certificate on one or more of the participating clusters using the Cluster Manager UI,
<code>
rladmin
</code>
, or the REST API. You can update a single cluster, multiple clusters, or all participating clusters.
</p>
</li>
<li>
<p>
Update the Active-Active database configuration from the command line with the
<a href="/docs/latest/operate/rs/references/cli-utilities/crdb-cli/">
<code>
crdb-cli
</code>
</a>
utility. Run this command once for each Active-Active database that resides on the modified clusters:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb update --crdb-guid <CRDB-GUID> --force
</span></span></code></pre>
</div>
</li>
</ol>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<ul>
<li>
Run step 2 as quickly as possible after step 1. Between the two steps, new syncer connections that use the βoldβ certificate will get rejected by the cluster that has been updated with the new certificate (in step 1).
<br/>
</li>
<li>
Do not run any other
<code>
crdb-cli crdb update
</code>
operations between the two steps.
<br/>
</li>
<li>
<strong>
Known limitation
</strong>
: Updating syncer certificate on versions prior to 6.0.20-81 will restart the proxy and syncer connections. In these cases, we recommend scheduling certificate replacement carefully to minimize customer impact.
</li>
</ul>
</div>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/security/certificates/updating-certificates/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/enslave/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin node enslave
</h1>
<p class="text-lg -mt-5 mb-10">
Changes a node's resources to replicas.
</p>
<p>
Changes the resources of a node to replicas.
</p>
<h2 id="node-enslave">
<code>
node enslave
</code>
</h2>
<p>
Changes all of the node's endpoints and shards to replicas.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> enslave
</span></span><span class="line"><span class="cl"> <span class="o">[</span>demote_node<span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span>retry_timeout_seconds <seconds><span class="o">]</span>
</span></span></code></pre>
</div>
<h3 id="parameters">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
node
</td>
<td>
integer
</td>
<td>
Changes all of the node's endpoints and shards to replicas
</td>
</tr>
<tr>
<td>
demote_node
</td>
<td>
</td>
<td>
If the node is a primary node, changes the node to replica
</td>
</tr>
<tr>
<td>
retry_timeout_seconds
</td>
<td>
integer
</td>
<td>
Retries on failure until the specified number of seconds has passed.
</td>
</tr>
</tbody>
</table>
<h3 id="returns">
Returns
</h3>
<p>
Returns
<code>
OK
</code>
if the roles were successfully changed. Otherwise, it returns an error.
</p>
<p>
Use
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/#status-shards">
<code>
rladmin status shards
</code>
</a>
to verify that the roles were changed.
</p>
<h3 id="example">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards node <span class="m">2</span>
</span></span><span class="line"><span class="cl">SHARDS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS
</span></span><span class="line"><span class="cl">db:6 tr02 redis:14 node:2 master 0-4095 3.2MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:16 node:2 master 4096-8191 3.12MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:18 node:2 master 8192-12287 3.16MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:20 node:2 master 12288-16383 3.12MB OK
</span></span><span class="line"><span class="cl">$ rladmin status nodes
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS CORES FREE_RAM PROVISIONAL_RAM VERSION STATUS
</span></span><span class="line"><span class="cl">*node:1 slave 192.0.2.12 198.51.100.1 3d99db1fdf4b 1/100 <span class="m">6</span> 14.43GB/19.54GB 10.87GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">node:2 master 192.0.2.13 198.51.100.2 fc7a3d332458 4/100 <span class="m">6</span> 14.43GB/19.54GB 10.88GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">node:3 slave 192.0.2.14 b87cc06c830f 5/120 <span class="m">6</span> 14.43GB/19.54GB 10.83GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">$ rladmin node <span class="m">2</span> enslave demote_node
</span></span><span class="line"><span class="cl">Performing enslave_node action on node:2: 100%
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">$ rladmin status nodes
</span></span><span class="line"><span class="cl">CLUSTER NODES:
</span></span><span class="line"><span class="cl">NODE:ID ROLE ADDRESS EXTERNAL_ADDRESS HOSTNAME SHARDS CORES FREE_RAM PROVISIONAL_RAM VERSION STATUS
</span></span><span class="line"><span class="cl">*node:1 master 192.0.2.12 198.51.100.1 3d99db1fdf4b 1/100 <span class="m">6</span> 14.72GB/19.54GB 10.91GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">node:2 slave 192.0.2.13 198.51.100.2 fc7a3d332458 4/100 <span class="m">6</span> 14.72GB/19.54GB 11.17GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">node:3 slave 192.0.2.14 b87cc06c830f 5/120 <span class="m">6</span> 14.72GB/19.54GB 10.92GB/16.02GB 6.2.12-37 OK
</span></span><span class="line"><span class="cl">$ rladmin status shards node <span class="m">2</span>
</span></span><span class="line"><span class="cl">SHARDS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS
</span></span><span class="line"><span class="cl">db:6 tr02 redis:14 node:2 slave 0-4095 2.99MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:16 node:2 slave 4096-8191 3.01MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:18 node:2 slave 8192-12287 2.93MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:20 node:2 slave 12288-16383 3.06MB OK
</span></span></code></pre>
</div>
<h2 id="node-enslave-endpoints_only">
<code>
node enslave endpoints_only
</code>
</h2>
<p>
Changes the role for all endpoints on a node to replica.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> enslave endpoints_only
</span></span><span class="line"><span class="cl"> <span class="o">[</span>retry_timeout_seconds <seconds><span class="o">]</span>
</span></span></code></pre>
</div>
<h3 id="parameters-1">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
node
</td>
<td>
integer
</td>
<td>
Changes all of the node's endpoints to replicas
</td>
</tr>
<tr>
<td>
retry_timeout_seconds
</td>
<td>
integer
</td>
<td>
Retries on failure until the specified number of seconds has passed.
</td>
</tr>
</tbody>
</table>
<h3 id="returns-1">
Returns
</h3>
<p>
Returns
<code>
OK
</code>
if the roles were successfully changed. Otherwise, it returns an error.
</p>
<p>
Use
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/#status-endpoints">
<code>
rladmin status endpoints
</code>
</a>
to verify that the roles were changed.
</p>
<h3 id="example-1">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status endpoints
</span></span><span class="line"><span class="cl">ENDPOINTS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SSL
</span></span><span class="line"><span class="cl">db:5 tr01 endpoint:5:1 node:1 single No
</span></span><span class="line"><span class="cl">db:6 tr02 endpoint:6:1 node:3 all-master-shards No
</span></span><span class="line"><span class="cl">$ rladmin node <span class="m">1</span> enslave endpoints_only
</span></span><span class="line"><span class="cl">Performing enslave_node action on node:1: 100%
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">$ rladmin status endpoints
</span></span><span class="line"><span class="cl">ENDPOINTS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SSL
</span></span><span class="line"><span class="cl">db:5 tr01 endpoint:5:1 node:3 single No
</span></span><span class="line"><span class="cl">db:6 tr02 endpoint:6:1 node:3 all-master-shards No
</span></span></code></pre>
</div>
<h2 id="node-enslave-shards_only">
<code>
node enslave shards_only
</code>
</h2>
<p>
Changes the role for all shards of a node to replica.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin node <ID> enslave shards_only
</span></span><span class="line"><span class="cl"> <span class="o">[</span>retry_timeout_seconds <seconds><span class="o">]</span>
</span></span></code></pre>
</div>
<h3 id="parameters-2">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
node
</td>
<td>
integer
</td>
<td>
Changes all of the node's shards to replicas
</td>
</tr>
<tr>
<td>
retry_timeout_seconds
</td>
<td>
integer
</td>
<td>
Retries on failure until the specified number of seconds has passed.
</td>
</tr>
</tbody>
</table>
<h3 id="returns-2">
Returns
</h3>
<p>
Returns
<code>
OK
</code>
if the roles were successfully changed. Otherwise, it returns an error.
</p>
<p>
Use
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/status/#status-shards">
<code>
rladmin status shards
</code>
</a>
to verify that the roles were changed.
</p>
<h3 id="example-2">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin status shards node <span class="m">3</span>
</span></span><span class="line"><span class="cl">SHARDS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS
</span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:3 master 0-16383 3.04MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:3 master 0-4095 4.13MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:3 master 4096-8191 4.13MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:3 master 8192-12287 4.13MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:3 master 12288-16383 4.13MB OK
</span></span><span class="line"><span class="cl">$ rladmin node <span class="m">3</span> enslave shards_only
</span></span><span class="line"><span class="cl">Performing enslave_node action on node:3: 100%
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">$ rladmin status shards node <span class="m">3</span>
</span></span><span class="line"><span class="cl">SHARDS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SLOTS USED_MEMORY STATUS
</span></span><span class="line"><span class="cl">db:5 tr01 redis:12 node:3 slave 0-16383 2.98MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:15 node:3 slave 0-4095 4.23MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:17 node:3 slave 4096-8191 4.11MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:19 node:3 slave 8192-12287 4.19MB OK
</span></span><span class="line"><span class="cl">db:6 tr02 redis:21 node:3 slave 12288-16383 4.27MB OK
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/rladmin/node/enslave/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.46.0/.html | <section class="prose w-full py-12">
<h1>
RedisInsight v2.46.0, March 2024
</h1>
<p class="text-lg -mt-5 mb-10">
RedisInsight v2.46
</p>
<h2 id="246-march-2024">
2.46 (March 2024)
</h2>
<p>
This is the General Availability (GA) release of RedisInsight 2.46.
</p>
<h3 id="highlights">
Highlights
</h3>
<ul>
<li>
New formatters for 32-bit and 64-bit vector embeddings for a more human-readable representation in the Browser
</li>
<li>
Cleaner layout on the main page with quick access to JSON and search & query tutorials and Redis Cloud in-app sign-up
</li>
</ul>
<h3 id="details">
Details
</h3>
<p>
<strong>
Features and improvements
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/2843">
#2843
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/3185">
#3185
</a>
Adding new formatters for 32-bit and 64-bit vector embeddings to visualize them as arrays in Browser for a simpler and more intuitive representation.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/3069">
#3069
</a>
UX enhancements in the database list page for an improved user experience, leading to a cleaner layout and easier navigation.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/3151">
#3151
</a>
Launch RedisInsight with the previously used window size.
</li>
</ul>
<p>
<strong>
Bugs
</strong>
</p>
<ul>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/3152">
#3152
</a>
,
<a href="https://github.com/RedisInsight/RedisInsight/pull/3156">
#3156
</a>
A fix to
<a href="https://github.com/RedisInsight/RedisInsight/issues/3146">
support the * wildcard
</a>
in Stream IDs.
</li>
<li>
<a href="https://github.com/RedisInsight/RedisInsight/pull/3174">
#3174
</a>
Display invalid JSONs as unformatted values when a JSON view is set in Workbench results.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/release-notes/v.2.46.0/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/ts.mget.html | <section class="prose w-full py-12">
<h1 class="command-name">
TS.MGET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TS.MGET [LATEST] [WITHLABELS | <SELECTED_LABELS label...>] FILTER filterExpr...
</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/timeseries">
TimeSeries 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(n) where n is the number of time-series that match the filters
</dd>
</dl>
<p>
Get the sample with the highest timestamp from each time series matching a specific filter
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
FILTER filterExpr...
</code>
</summary>
<p>
filters time series based on their labels and label values. Each filter expression has one of the following syntaxes:
</p>
<ul>
<li>
<code>
label!=
</code>
- the time series has a label named
<code>
label
</code>
</li>
<li>
<code>
label=value
</code>
- the time series has a label named
<code>
label
</code>
with a value equal to
<code>
value
</code>
</li>
<li>
<code>
label=(value1,value2,...)
</code>
- the time series has a label named
<code>
label
</code>
with a value equal to one of the values in the list
</li>
<li>
<code>
label=
</code>
- the time series does not have a label named
<code>
label
</code>
</li>
<li>
<code>
label!=value
</code>
- the time series does not have a label named
<code>
label
</code>
with a value equal to
<code>
value
</code>
</li>
<li>
<code>
label!=(value1,value2,...)
</code>
- the time series does not have a label named
<code>
label
</code>
with a value equal to any of the values in the list
</li>
</ul>
<p>
<note>
<b>
Notes:
</b>
</note>
</p>
<ul>
<li>
At least one filter expression with a syntax
<code>
label=value
</code>
or
<code>
label=(value1,value2,...)
</code>
is required.
</li>
<li>
Filter expressions are conjunctive. For example, the filter
<code>
type=temperature room=study
</code>
means that a time series is a temperature time series of a study room.
</li>
<li>
Whitespaces are unallowed in a filter expression except between quotes or double quotes in values - e.g.,
<code>
x="y y"
</code>
or
<code>
x='(y y,z z)'
</code>
.
</li>
</ul>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
LATEST
</code>
(since RedisTimeSeries v1.8)
</summary>
<p>
is used when a time series is a compaction. With
<code>
LATEST
</code>
, TS.MGET also reports the compacted value of the latest (possibly partial) bucket, given that this bucket's start time falls within
<code>
[fromTimestamp, toTimestamp]
</code>
. Without
<code>
LATEST
</code>
, TS.MGET does not report the latest (possibly partial) bucket. When a time series is not a compaction,
<code>
LATEST
</code>
is ignored.
</p>
<p>
The data in the latest bucket of a compaction is possibly partial. A bucket is
<em>
closed
</em>
and compacted only upon the arrival of a new sample that
<em>
opens
</em>
a new
<em>
latest
</em>
bucket. There are cases, however, when the compacted value of the latest (possibly partial) bucket is also required. In such a case, use
<code>
LATEST
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
WITHLABELS
</code>
</summary>
<p>
includes in the reply all label-value pairs representing metadata labels of the time series.
If
<code>
WITHLABELS
</code>
or
<code>
SELECTED_LABELS
</code>
are not specified, by default, an empty list is reported as label-value pairs.
</p>
</details>
<details open="">
<summary>
<code>
SELECTED_LABELS label...
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
returns a subset of the label-value pairs that represent metadata labels of the time series.
Use when a large number of labels exists per series, but only the values of some of the labels are required.
If
<code>
WITHLABELS
</code>
or
<code>
SELECTED_LABELS
</code>
are not specified, by default, an empty list is reported as label-value pairs.
</p>
</details>
<p>
<note>
<b>
Note:
</b>
The
<a href="/docs/latest/commands/mget/">
<code>
MGET
</code>
</a>
command cannot be part of a transaction when running on a Redis cluster.
</note>
</p>
<h2 id="return-value">
Return value
</h2>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: for each time series matching the specified filters, the following is reported:
<ul>
<li>
bulk-string-reply: The time series key name
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: label-value pairs (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
)
<ul>
<li>
By default, an empty array is reported
</li>
<li>
If
<code>
WITHLABELS
</code>
is specified, all labels associated with this time series are reported
</li>
<li>
If
<code>
SELECTED_LABELS label...
</code>
is specified, the selected labels are reported (null value when no such label defined)
</li>
</ul>
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: a single timestamp-value pair (
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
(double))
</li>
</ul>
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Select labels to retrieve
</b>
</summary>
<p>
Create time series for temperature in Tel Aviv and Jerusalem, then add different temperature samples.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE temp:TLV LABELS <span class="nb">type</span> temp location TLV
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE temp:JLM LABELS <span class="nb">type</span> temp location JLM
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD temp:TLV <span class="m">1000</span> <span class="m">30</span> temp:TLV <span class="m">1010</span> <span class="m">35</span> temp:TLV <span class="m">1020</span> <span class="m">9999</span> temp:TLV <span class="m">1030</span> <span class="m">40</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span>
</span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1030</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD temp:JLM <span class="m">1005</span> <span class="m">30</span> temp:JLM <span class="m">1015</span> <span class="m">35</span> temp:JLM <span class="m">1025</span> <span class="m">9999</span> temp:JLM <span class="m">1035</span> <span class="m">40</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1005</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1015</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1025</span>
</span></span><span class="line"><span class="cl">4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1035</span></span></span></code></pre>
</div>
<p>
Get all the labels associated with the last sample.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.MGET WITHLABELS FILTER <span class="nv">type</span><span class="o">=</span>temp
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"temp:JLM"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"temp"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"location"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"JLM"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1035</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">40</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"temp:TLV"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"temp"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"location"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"TLV"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1030</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">40</span></span></span></code></pre>
</div>
<p>
To get only the
<code>
location
</code>
label for each last sample, use
<code>
SELECTED_LABELS
</code>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.MGET SELECTED_LABELS location FILTER <span class="nv">type</span><span class="o">=</span>temp
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"temp:JLM"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"location"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"JLM"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1035</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">40</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"temp:TLV"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"location"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"TLV"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1030</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">40</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ts.mrange/">
<code>
TS.MRANGE
</code>
</a>
|
<a href="/docs/latest/commands/ts.range/">
<code>
TS.RANGE
</code>
</a>
|
<a href="/docs/latest/commands/ts.mrevrange/">
<code>
TS.MREVRANGE
</code>
</a>
|
<a href="/docs/latest/commands/ts.revrange/">
<code>
TS.REVRANGE
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<p>
<a href="/docs/latest/develop/data-types/timeseries/">
RedisTimeSeries
</a>
</p>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.mget/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/auth/.html | <section class="prose w-full py-12">
<h1 class="command-name">
AUTH
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">AUTH [username] password</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
1.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) where N is the number of passwords defined for the user
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@connection
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The AUTH command authenticates the current connection in two cases:
</p>
<ol>
<li>
If the Redis server is password protected via the
<code>
requirepass
</code>
option.
</li>
<li>
A Redis 6.0 instance, or greater, is using the
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/">
Redis ACL system
</a>
.
</li>
</ol>
<p>
Redis versions prior of Redis 6 were only able to understand the one argument
version of the command:
</p>
<pre><code>AUTH <password>
</code></pre>
<p>
This form just authenticates against the password set with
<code>
requirepass
</code>
.
In this configuration Redis will deny any command executed by the just
connected clients, unless the connection gets authenticated via
<code>
AUTH
</code>
.
</p>
<p>
If the password provided via AUTH matches the password in the configuration file, the server replies with the
<code>
OK
</code>
status code and starts accepting commands.
Otherwise, an error is returned and the clients needs to try a new password.
</p>
<p>
When Redis ACLs are used, the command should be given in an extended way:
</p>
<pre><code>AUTH <username> <password>
</code></pre>
<p>
In order to authenticate the current connection with one of the connections
defined in the ACL list (see
<a href="/docs/latest/commands/acl-setuser/">
<code>
ACL SETUSER
</code>
</a>
) and the official
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/">
ACL guide
</a>
for more information.
</p>
<p>
When ACLs are used, the single argument form of the command, where only the password is specified, assumes that the implicit username is "default".
</p>
<h2 id="security-notice">
Security notice
</h2>
<p>
Because of the high performance nature of Redis, it is possible to try
a lot of passwords in parallel in very short time, so make sure to generate a
strong and very long password so that this attack is infeasible.
A good way to generate strong passwords is via the
<a href="/docs/latest/commands/acl-genpass/">
<code>
ACL GENPASS
</code>
</a>
command.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
, or an error if the password, or username/password pair, is invalid.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 6.0.0: Added ACL style (username and password).
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/auth/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/networking/istio-ingress/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Configure Istio for external routing
</h1>
<p class="text-lg -mt-5 mb-10">
Configure Istio as an ingress controller for access to your Redis Enterprise databases from outside the Kubernetes cluster.
</p>
<p>
Redis Enterprise for Kubernetes has the ability to use an Istio Ingress gateway as an alternative to NGINX or HaProxy Ingress controllers.
</p>
<p>
Istio can also understand Ingress resources, but using that mechanism takes away the advantages and options that the native Istio resources provide. Istio offers its own configuration methods using custom resources.
</p>
<p>
To configure Istio to work with the Redis Kubernetes operator, we will use two custom resources: a
<code>
Gateway
</code>
and a
<code>
VirtualService
</code>
. Then you'll be able to establish external access to your database.
</p>
<h2 id="install-and-configure-istio-for-redis-enterprise">
Install and configure Istio for Redis Enterprise
</h2>
<ol>
<li>
<p>
<a href="https://istio.io/latest/docs/setup/getting-started/">
Download
</a>
and
<a href="https://istio.io/latest/docs/setup/getting-started/">
install
</a>
Istio (see instructions from Istio's
<a href="https://istio.io/latest/docs/setup/getting-started/">
Getting Started
</a>
guide).
</p>
<p>
Once the installation is complete, all the deployments, pods, and services will be deployed in a namespace called
<code>
istio-system
</code>
. This namespace contains a
<code>
LoadBalancer
</code>
type service called
<code>
service/istio-ingressgateway
</code>
that exposes the external IP address.
</p>
</li>
<li>
<p>
Find the
<code>
EXTERNAL-IP
</code>
for the
<code>
istio-ingressgateway
</code>
service.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get svc istio-ingressgateway -n istio-system
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">NAME TYPE CLUSTER-IP EXTERNAL-IP PORT<span class="o">(</span>S<span class="o">)</span> AGE
</span></span><span class="line"><span class="cl">istio-ingressgateway LoadBalancer 10.34.67.89 10.145.78.91 15021:12345/TCP,80:67891/TCP,443:23456/TCP,31400:78901/TCP,15443:10112/TCP 3h8m
</span></span></code></pre>
</div>
</li>
<li>
<p>
Create a DNS entry that resolves your chosen database hostname (or a wildcard
<code>
*
</code>
followed by your domain) to the Istio
<code>
EXTERNAL-IP
</code>
. Use this hostname to access your database from outside the cluster.
</p>
<p>
In this example, any hostname that ends with
<code>
.istio.k8s.my.example.com
</code>
will resolve to the Istio LoadBalancer's external IP of
<code>
10.145.78.91
</code>
. Substitute your own values accordingly.
</p>
</li>
<li>
<p>
Verify the record was created successfully.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">dig api.istio.k8s.my.example.com
</span></span></code></pre>
</div>
<p>
Look in the
<code>
ANSWER SECTION
</code>
for the record you just created.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="p">;;</span> ANSWER SECTION:
</span></span><span class="line"><span class="cl">api.istio.k8s.my.example.com <span class="m">0</span> IN A 10.145.78.91
</span></span></code></pre>
</div>
</li>
</ol>
<h2 id="create-custom-resources">
Create custom resources
</h2>
<h3 id="gateway-custom-resource">
<code>
Gateway
</code>
custom resource
</h3>
<ol>
<li>
<p>
On a different namespace from
<code>
istio-system
</code>
, create a
<code>
Gateway
</code>
custom resource file (
<code>
redis-gateway.yaml
</code>
in this example).
</p>
<ul>
<li>
Replace
<code>
.istio.k8s.my.example.com
</code>
with the domain that matches your DNS record.
</li>
<li>
Replace
<code>
<selector-label>
</code>
with the label set on your Istio ingress gateway pod (most common is
<code>
istio: ingress
</code>
).
</li>
<li>
TLS passthrough mode is required to allow secure access to the database.
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">networking.istio.io/v1beta1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Gateway</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redis-gateway</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">istio</span><span class="p">:</span><span class="w"> </span><span class="l"><selector-label></span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">servers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">hosts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="s1">'*.istio.k8s.my.example.com'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">port</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">https</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">number</span><span class="p">:</span><span class="w"> </span><span class="m">443</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">protocol</span><span class="p">:</span><span class="w"> </span><span class="l">HTTPS</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">tls</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mode</span><span class="p">:</span><span class="w"> </span><span class="l">PASSTHROUGH</span><span class="w">
</span></span></span></code></pre>
</div>
</li>
<li>
<p>
Apply the
<code>
Gateway
</code>
custom resource file to create the Ingress gateway.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f redis-gateway.yaml
</span></span></code></pre>
</div>
</li>
<li>
<p>
Verify the gateway was created successfully.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get gateway
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">NAME AGE
</span></span><span class="line"><span class="cl">redis-gateway 3h33m
</span></span></code></pre>
</div>
</li>
</ol>
<h3 id="virtualservice-custom-resource">
<code>
VirtualService
</code>
custom resource
</h3>
<ol>
<li>
<p>
On a different namespace than
<code>
istio-system
</code>
, create the
<code>
VirtualService
</code>
custom resource file (
<code>
redis-vs.yaml
</code>
in this example).
</p>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">networking.istio.io/v1beta1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">VirtualService</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redis-vs</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">gateways</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">redis-gateway</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">hosts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="s2">"*.istio.k8s.my.example.com"</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">tls</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">match</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="m">443</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">sniHosts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">api.istio.k8s.my.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">route</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">destination</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">host</span><span class="p">:</span><span class="w"> </span><span class="l">rec1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">port</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">number</span><span class="p">:</span><span class="w"> </span><span class="m">9443</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">match</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="m">443</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">sniHosts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">db1.istio.k8s.my.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">route</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">destination</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">host</span><span class="p">:</span><span class="w"> </span><span class="l">db1</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
This creates both a route to contact the API server on the REC (
<code>
rec1
</code>
) and a route to contact one of the databases (
<code>
db1
</code>
).
</p>
<ul>
<li>
Replace
<code>
.istio.k8s.my.example.com
</code>
with the domain that matches your DNS record.
</li>
<li>
The gateway's metadata name must be similar to the gateway's spec name (
<code>
redis-gateway
</code>
in this example).
</li>
</ul>
</li>
<li>
<p>
Apply
<code>
VirtualService
</code>
custom resource file to create the virtual service.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f redis-vs.yaml
</span></span></code></pre>
</div>
</li>
<li>
<p>
Verify the virtual service was created successfully.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get vs
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">NAME GATEWAYS HOSTS AGE
</span></span><span class="line"><span class="cl">redis-vs <span class="o">[</span><span class="s2">"redis-gateway"</span><span class="o">]</span> <span class="o">[</span><span class="s2">"*.istio.k8s.my.example.com"</span><span class="o">]</span> 3h33m
</span></span></code></pre>
</div>
</li>
<li>
<p>
<a href="/docs/latest/operate/kubernetes/deployment/quick-start/">
Deploy the operator
</a>
, Redis Enterprise Cluster (REC), and Redis Enterprise Database (REDB) on the same namespace as the gateway and virtual service.
</p>
</li>
</ol>
<h2 id="test-your-external-access-to-the-database">
Test your external access to the database
</h2>
<p>
To
<a href="/docs/latest/operate/kubernetes/networking/ingress/">
test your external access
</a>
to the database, you need a client that supports
<a href="https://en.wikipedia.org/wiki/Transport_Layer_Security">
TLS
</a>
and
<a href="https://en.wikipedia.org/wiki/Server_Name_Indication">
SNI
</a>
.
</p>
<p>
See
<a href="/docs/latest/operate/kubernetes/networking/ingress/#test-your-access-with-openssl">
Test your access with Openssl
</a>
or
<a href="/docs/latest/operate/kubernetes/networking/ingress/#test-your-access-with-python">
Test your access with Python
</a>
for more info.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/networking/istio-ingress/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/tools/insight/debugging/.html | <section class="prose w-full py-12">
<h1>
Redis Insight debugging information
</h1>
<p class="text-lg -mt-5 mb-10">
Redis Insight debugging information
</p>
<p>
If you are experiencing errors or other issues when using Redis Insight, follow the steps below to learn more about the errors and to identify root cause.
</p>
<h2 id="connection-issues">
Connection issues
</h2>
<p>
If you experience connection issues, try these steps.
</p>
<h3 id="1-launch-redis-insight-in-debug-mode">
1. Launch Redis Insight in debug mode
</h3>
<p>
Run the following command to launch Redis Insight in debug mode to investigate connection issues:
</p>
<ul>
<li>
<p>
<strong>
Windows
</strong>
:
</p>
<p>
<code>
cmd /C βset DEBUG=ioredis* && ".\Redis Insight.exe"β
</code>
</p>
</li>
<li>
<p>
<strong>
macOS
</strong>
(from the Applications folder):
</p>
<p>
<code>
DEBUG=ioredis* open "Redis Insight.app"
</code>
</p>
</li>
<li>
<p>
<strong>
Linux
</strong>
:
</p>
<p>
<code>
DEBUG=ioredis* "redis insight"
</code>
</p>
</li>
</ul>
<h3 id="2-investigate-logs">
2. Investigate logs
</h3>
<p>
You can review the Redis Insight log files (files with a
<code>
.log
</code>
extension) to get detailed information about system issues.
These are the locations on supported platforms:
</p>
<ul>
<li>
<strong>
Docker
</strong>
: In the
<code>
/data/logs
</code>
directory
<em>
inside the container
</em>
.
</li>
<li>
<strong>
macOS
</strong>
: In the
<code>
/Users/<your-username>/.redis-insight
</code>
directory.
</li>
<li>
<strong>
Windows
</strong>
: In the
<code>
C:\Users\<your-username>\.redis-insight
</code>
directory.
</li>
<li>
<strong>
Linux
</strong>
: In the
<code>
/home/<your-username>/.redis-insight
</code>
directory.
</li>
</ul>
<h2 id="other-issues">
Other issues
</h2>
<h3 id="to-debug-issues-other-than-connectivity">
To debug issues other than connectivity
</h3>
<ul>
<li>
<p>
<strong>
Windows
</strong>
:
</p>
<p>
<code>
cmd /C βset DEBUG=* && ".\Redis Insight.exe"β
</code>
</p>
</li>
<li>
<p>
<strong>
macOS
</strong>
(from the Applications folder):
</p>
<p>
<code>
DEBUG=* open "Redis Insight.app"
</code>
</p>
</li>
<li>
<p>
<strong>
Linux
</strong>
:
</p>
<p>
<code>
DEBUG=* "redis insight"
</code>
</p>
</li>
</ul>
<h3 id="get-detailed-redis-insight-logs">
Get detailed Redis Insight logs
</h3>
<ul>
<li>
<p>
<strong>
Windows
</strong>
:
</p>
<p>
<code>
cmd /C βset STDOUT_LOGGER=true && set LOG_LEVEL=debug && set LOGGER_OMIT_DATA=false && ".\Redis Insight.exe"β
</code>
</p>
</li>
<li>
<p>
<strong>
macOS
</strong>
(from the Applications folder):
</p>
<p>
<code>
LOG_LEVEL=debug LOGGER_OMIT_DATA=false open "Redis Insight.app"
</code>
</p>
</li>
<li>
<p>
<strong>
Linux
</strong>
:
</p>
<p>
<code>
LOG_LEVEL=debug LOGGER_OMIT_DATA=false "redis insight"
</code>
</p>
<p>
Note: if you use LOGGER_OMIT_DATA=false, logs may contain sensitive data.
</p>
</li>
</ul>
<h3 id="to-log-everything">
To log everything
</h3>
<ul>
<li>
<p>
<strong>
Windows
</strong>
:
</p>
<p>
<code>
cmd /C βset STDOUT_LOGGER=true && set LOG_LEVEL=debug && set LOGGER_OMIT_DATA=false && set DEBUG=* && ".\Redis Insight.exe"β
</code>
</p>
</li>
<li>
<p>
<strong>
macOS
</strong>
(from the Applications folder):
</p>
<p>
<code>
LOG_LEVEL=debug LOGGER_OMIT_DATA=false DEBUG=* open "Redis Insight.app"
</code>
</p>
</li>
<li>
<p>
<strong>
Linux
</strong>
:
</p>
<p>
<code>
LOG_LEVEL=debug LOGGER_OMIT_DATA=false DEBUG=* "redis insight"
</code>
</p>
<p>
Note: if you use LOGGER_OMIT_DATA=false or DEBUG=*, logs may contain sensitive data.
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/tools/insight/debugging/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/tdigest.add.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.ADD
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.ADD key value [value ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 2.4.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) , where N is the number of samples to add
</dd>
</dl>
<p>
Adds one or more observations to a t-digest sketch.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
is key name for an existing t-digest sketch.
</details>
<details open="">
<summary>
<code>
value
</code>
</summary>
is value of an observation (floating-point).
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
-
<code>
OK
</code>
if executed correctly, or [] otherwise.
</p>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">3</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> TDIGEST.ADD t string
</span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> ERR T-Digest: error parsing val parameter</span></span></code></pre>
</div>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/tdigest.add/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-set-context/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di set-context
</h1>
<p class="text-lg -mt-5 mb-10">
Sets a context to be the active one
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di set-context [OPTIONS] CONTEXT_NAME
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
loglevel
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--loglevel -log-level
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
context_name
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
context-name
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
help
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--help
</code>
</li>
</ul>
<p>
Show this message and exit.
</p>
</li>
</ul>
<h2 id="cli-help">
CLI help
</h2>
<pre tabindex="0"><code>Usage: redis-di set-context [OPTIONS] CONTEXT_NAME
Sets a context to be the active one
Options:
-log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
--help Show this message and exit.
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-set-context/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/json.get/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.GET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.GET key [INDENTΒ indent] [NEWLINEΒ newline] [SPACEΒ space] [path
[path ...]]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/json">
JSON 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) when path is evaluated to a single value where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Return the value at
<code>
path
</code>
in JSON serialized form
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key to parse.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
. JSON.GET accepts multiple
<code>
path
</code>
arguments.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<p>
When using a single JSONPath, the root of the matching values is a JSON string with a top-level
<strong>
array
</strong>
of serialized JSON value.
In contrast, a legacy path returns a single value.
</p>
<p>
When using multiple JSONPath arguments, the root of the matching values is a JSON string with a top-level
<strong>
object
</strong>
, with each object value being a top-level array of serialized JSON value.
In contrast, if all paths are legacy paths, each object value is a single serialized JSON value.
If there are multiple paths that include both legacy path and JSONPath, the returned value conforms to the JSONPath version (an array of values).
</p>
</div>
</div>
</details>
<details open="">
<summary>
<code>
INDENT
</code>
</summary>
<p>
sets the indentation string for nested levels.
</p>
</details>
<details open="">
<summary>
<code>
NEWLINE
</code>
</summary>
<p>
sets the string that's printed at the end of each line.
</p>
</details>
<details open="">
<summary>
<code>
SPACE
</code>
</summary>
<p>
sets the string that's put between a key and a value.
</p>
</details>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
<p>
Produce pretty-formatted JSON with
<code>
redis-cli
</code>
by following this example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">~/$ redis-cli --raw
</span></span><span class="line"><span class="cl">redis> JSON.GET myjsonkey INDENT <span class="s2">"\t"</span> NEWLINE <span class="s2">"\n"</span> SPACE <span class="s2">" "</span> path.to.value<span class="o">[</span>1<span class="o">]</span></span></span></code></pre>
</div>
</div>
</div>
<h2 id="return">
Return
</h2>
<p>
JSON.GET returns a bulk string representing a JSON array of string replies.
Each string is the JSON serialization of each JSON value that matches a path.
Using multiple paths, JSON.GET returns a bulk string representing a JSON object with string values.
Each string value is an array of the JSON serialization of each JSON value that matches a path.
For more information about replies, see
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Return the value at
<code>
path
</code>
in JSON serialized form
</b>
</summary>
<p>
Create a JSON document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET doc $ <span class="s1">'{"a":2, "b": 3, "nested": {"a": 4, "b": null}}'</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
With a single JSONPath (JSON array bulk string):
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET doc $..b
</span></span><span class="line"><span class="cl"><span class="s2">"[3,null]"</span></span></span></code></pre>
</div>
<p>
Using multiple paths with at least one JSONPath returns a JSON string with a top-level object with an array of JSON values per path:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET doc ..a $..b
</span></span><span class="line"><span class="cl"><span class="s2">"{\"</span>$<span class="s2">..b\":[3,null],\"..a\":[2,4]}"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/json.set/">
<code>
JSON.SET
</code>
</a>
|
<a href="/docs/latest/commands/json.mget/">
<code>
JSON.MGET
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/data-types/json/">
RedisJSON
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
Index and search JSON documents
</a>
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.get/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/cms.incrby.html | <section class="prose w-full py-12">
<h1 class="command-name">
CMS.INCRBY
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CMS.INCRBY key item increment [item increment ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 2.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(n) where n is the number of items
</dd>
</dl>
<p>
Increases the count of item by increment. Multiple items can be increased with one call.
</p>
<h3 id="parameters">
Parameters:
</h3>
<ul>
<li>
<strong>
key
</strong>
: The name of the sketch.
</li>
<li>
<strong>
item
</strong>
: The item which counter is to be increased.
</li>
<li>
<strong>
increment
</strong>
: Amount by which the item counter is to be increased.
</li>
</ul>
<h2 id="return">
Return
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
of
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
with an updated min-count of each of the items in the sketch.
</p>
<p>
Count of each item after increment.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>redis> CMS.INCRBY test foo 10 bar 42
1) (integer) 10
2) (integer) 42
</code></pre>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cms.incrby/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/shutdown/.html | <section class="prose w-full py-12">
<h1 class="command-name">
SHUTDOWN
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">SHUTDOWN [NOSAVE | SAVE] [NOW] [FORCE] [ABORT]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
1.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) when saving, where N is the total number of keys in all databases when saving data, otherwise O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@admin
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@dangerous
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The command behavior is the following:
</p>
<ul>
<li>
If there are any replicas lagging behind in replication:
<ul>
<li>
Pause clients attempting to write by performing a
<a href="/docs/latest/commands/client-pause/">
<code>
CLIENT PAUSE
</code>
</a>
with the
<code>
WRITE
</code>
option.
</li>
<li>
Wait up to the configured
<code>
shutdown-timeout
</code>
(default 10 seconds) for replicas to catch up the replication offset.
</li>
</ul>
</li>
<li>
Stop all the clients.
</li>
<li>
Perform a blocking SAVE if at least one
<strong>
save point
</strong>
is configured.
</li>
<li>
Flush the Append Only File if AOF is enabled.
</li>
<li>
Quit the server.
</li>
</ul>
<p>
If persistence is enabled this commands makes sure that Redis is switched off
without any data loss.
</p>
<p>
Note: A Redis instance that is configured for not persisting on disk (no AOF
configured, nor "save" directive) will not dump the RDB file on
<code>
SHUTDOWN
</code>
, as
usually you don't want Redis instances used only for caching to block on when
shutting down.
</p>
<p>
Also note: If Redis receives one of the signals
<code>
SIGTERM
</code>
and
<code>
SIGINT
</code>
, the same shutdown sequence is performed.
See also
<a href="/docs/latest/operate/oss_and_stack/reference/signals/">
Signal Handling
</a>
.
</p>
<h2 id="modifiers">
Modifiers
</h2>
<p>
It is possible to specify optional modifiers to alter the behavior of the command.
Specifically:
</p>
<ul>
<li>
<strong>
SAVE
</strong>
will force a DB saving operation even if no save points are configured.
</li>
<li>
<strong>
NOSAVE
</strong>
will prevent a DB saving operation even if one or more save points are configured.
</li>
<li>
<strong>
NOW
</strong>
skips waiting for lagging replicas, i.e. it bypasses the first step in the shutdown sequence.
</li>
<li>
<strong>
FORCE
</strong>
ignores any errors that would normally prevent the server from exiting.
For details, see the following section.
</li>
<li>
<strong>
ABORT
</strong>
cancels an ongoing shutdown and cannot be combined with other flags.
</li>
</ul>
<h2 id="conditions-where-a-shutdown-fails">
Conditions where a SHUTDOWN fails
</h2>
<p>
When a save point is configured or the
<strong>
SAVE
</strong>
modifier is specified, the shutdown may fail if the RDB file can't be saved.
Then, the server continues to run in order to ensure no data loss.
This may be bypassed using the
<strong>
FORCE
</strong>
modifier, causing the server to exit anyway.
</p>
<p>
When the Append Only File is enabled the shutdown may fail because the
system is in a state that does not allow to safely immediately persist
on disk.
</p>
<p>
Normally if there is an AOF child process performing an AOF rewrite, Redis
will simply kill it and exit.
However, there are situations where it is unsafe to do so and, unless the
<strong>
FORCE
</strong>
modifier is specified, the
<strong>
SHUTDOWN
</strong>
command will be refused with an error instead.
This happens in the following situations:
</p>
<ul>
<li>
The user just turned on AOF, and the server triggered the first AOF rewrite in order to create the initial AOF file. In this context, stopping will result in losing the dataset at all: once restarted, the server will potentially have AOF enabled without having any AOF file at all.
</li>
<li>
A replica with AOF enabled, reconnected with its master, performed a full resynchronization, and restarted the AOF file, triggering the initial AOF creation process. In this case not completing the AOF rewrite is dangerous because the latest dataset received from the master would be lost. The new master can actually be even a different instance (if the
<strong>
REPLICAOF
</strong>
or
<strong>
SLAVEOF
</strong>
command was used in order to reconfigure the replica), so it is important to finish the AOF rewrite and start with the correct data set representing the data set in memory when the server was terminated.
</li>
</ul>
<p>
There are situations when we want just to terminate a Redis instance ASAP, regardless of what its content is.
In such a case, the command
<strong>
SHUTDOWN NOW NOSAVE FORCE
</strong>
can be used.
In versions before 7.0, where the
<strong>
NOW
</strong>
and
<strong>
FORCE
</strong>
flags are not available, the right combination of commands is to send a
<strong>
CONFIG appendonly no
</strong>
followed by a
<strong>
SHUTDOWN NOSAVE
</strong>
.
The first command will turn off the AOF if needed, and will terminate the AOF rewriting child if there is one active.
The second command will not have any problem to execute since the AOF is no longer enabled.
</p>
<h2 id="minimize-the-risk-of-data-loss">
Minimize the risk of data loss
</h2>
<p>
Since Redis 7.0, the server waits for lagging replicas up to a configurable
<code>
shutdown-timeout
</code>
, by default 10 seconds, before shutting down.
This provides a best effort minimizing the risk of data loss in a situation where no save points are configured and AOF is disabled.
Before version 7.0, shutting down a heavily loaded master node in a diskless setup was more likely to result in data loss.
To minimize the risk of data loss in such setups, it's advised to trigger a manual
<a href="/docs/latest/commands/failover/">
<code>
FAILOVER
</code>
</a>
(or
<a href="/docs/latest/commands/cluster-failover/">
<code>
CLUSTER FAILOVER
</code>
</a>
) to demote the master to a replica and promote one of the replicas to be the new master, before shutting down a master node.
</p>
<h2 id="behavior-change-history">
Behavior change history
</h2>
<ul>
<li>
<code>
>= 7.0.0
</code>
: Introduced waiting for lagging replicas before exiting.
</li>
</ul>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
if
<em>
ABORT
</em>
was specified and shutdown was aborted. On successful shutdown, nothing is returned because the server quits and the connection is closed. On failure, an error is returned.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Added the
<code>
NOW
</code>
,
<code>
FORCE
</code>
and
<code>
ABORT
</code>
modifiers.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/shutdown/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Stack and Redis Enterprise
</h1>
<p>
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
and
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
support all
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/enterprise-capabilities/">
Redis Stack
</a>
features, which extend the core Redis feature set. Some of the capabilities Redis Stack provides include querying, indexing, and full-text search and support for JSON, time series, and probabilistic data structures.
</p>
<nav>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/stack-quickstart/">
Redis Stack quick start
</a>
<br/>
<br/>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/">
Install and upgrade modules
</a>
<br/>
<br/>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/modules-lifecycle/">
Module lifecycle
</a>
<br/>
<br/>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/enterprise-capabilities/">
Redis Enterprise and Redis Stack feature compatibility
</a>
<p>
Describes the Redis Enterprise features supported by each Redis Stack feature.
</p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/search/">
Search and query
</a>
<br/>
<br/>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/json/">
JSON
</a>
<p>
Redis Stack adds support for JSON to Redis databases.
</p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/timeseries/">
Time series
</a>
<br/>
<br/>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/bloom/">
Probabilistic data structures
</a>
<p>
Probabilistic data structures
</p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/gears-v1/">
Gears
</a>
<p>
RedisGears supports batch and event-driven processing for Redis data.
</p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/">
Deprecated Redis Stack features and modules
</a>
<p>
Features (modules) that have been deprecated or replaced with a new version.
</p>
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/release-notes/">
Redis Stack and modules release notes
</a>
<p>
Redis Stack and modules release notes
</p>
</nav>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/cluster-links/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CLUSTER LINKS
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CLUSTER LINKS</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
7.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) where N is the total number of Cluster nodes
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Each node in a Redis Cluster maintains a pair of long-lived TCP link with each peer in the cluster: One for sending outbound messages towards the peer and one for receiving inbound messages from the peer.
</p>
<p>
<code>
CLUSTER LINKS
</code>
outputs information of all such peer links as an array, where each array element is a map that contains attributes and their values for an individual link.
</p>
<h2 id="examples">
Examples
</h2>
<p>
The following is an example output:
</p>
<pre tabindex="0"><code>> CLUSTER LINKS
1) 1) "direction"
2) "to"
3) "node"
4) "8149d745fa551e40764fecaf7cab9dbdf6b659ae"
5) "create-time"
6) (integer) 1639442739375
7) "events"
8) "rw"
9) "send-buffer-allocated"
10) (integer) 4512
11) "send-buffer-used"
12) (integer) 0
2) 1) "direction"
2) "from"
3) "node"
4) "8149d745fa551e40764fecaf7cab9dbdf6b659ae"
5) "create-time"
6) (integer) 1639442739411
7) "events"
8) "r"
9) "send-buffer-allocated"
10) (integer) 0
11) "send-buffer-used"
12) (integer) 0
</code></pre>
<p>
Each map is composed of the following attributes of the corresponding cluster link and their values:
</p>
<ol>
<li>
<code>
direction
</code>
: This link is established by the local node
<code>
to
</code>
the peer, or accepted by the local node
<code>
from
</code>
the peer.
</li>
<li>
<code>
node
</code>
: The node id of the peer.
</li>
<li>
<code>
create-time
</code>
: Creation time of the link. (In the case of a
<code>
to
</code>
link, this is the time when the TCP link is created by the local node, not the time when it is actually established.)
</li>
<li>
<code>
events
</code>
: Events currently registered for the link.
<code>
r
</code>
means readable event,
<code>
w
</code>
means writable event.
</li>
<li>
<code>
send-buffer-allocated
</code>
: Allocated size of the link's send buffer, which is used to buffer outgoing messages toward the peer.
</li>
<li>
<code>
send-buffer-used
</code>
: Size of the portion of the link's send buffer that is currently holding data(messages).
</li>
</ol>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: an array of maps where each map contains various attributes and their values of a cluster link.
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: an array of
<a href="../../develop/reference/protocol-spec#maps">
Map reply
</a>
where each map contains various attributes and their values of a cluster link.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cluster-links/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/redisvl/api/cache/.html | <section class="prose w-full py-12 max-w-none">
<h1>
LLMCache
</h1>
<p class="text-lg -mt-5 mb-10">
The LLMCache APIs
</p>
<h2 id="semanticcache">
SemanticCache
</h2>
<p>
<a id="semantic-cache-api">
</a>
</p>
<h3 id="class-semanticcachenamellmcache-prefixnone-distance_threshold01-ttlnone-vectorizerhftextvectorizermodelsentence-transformersall-mpnet-base-v2-dims768-clientsentencetransformer---0-transformermax_seq_length-384-do_lower_case-false-with-transformer-model-mpnetmodel----1-poolingword_embedding_dimension-768-pooling_mode_cls_token-false-pooling_mode_mean_tokens-true-pooling_mode_max_tokens-false-pooling_mode_mean_sqrt_len_tokens-false-pooling_mode_weightedmean_tokens-false-pooling_mode_lasttoken-false---2-normalize--redis_clientnone-redis_urlredislocalhost6379-connection_args-kwargs">
<em>
class
</em>
SemanticCache(name='llmcache', prefix=None, distance_threshold=0.1, ttl=None, vectorizer=HFTextVectorizer(model='sentence-transformers/all-mpnet-base-v2', dims=768, client=SentenceTransformer( (0): Transformer({'max_seq_length': 384, 'do_lower_case': False}) with Transformer model: MPNetModel (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False}) (2): Normalize() )), redis_client=None, redis_url='redis://localhost:6379', connection_args={}, **kwargs)
</h3>
<p>
Bases:
<code>
BaseLLMCache
</code>
</p>
<p>
Semantic Cache for Large Language Models.
</p>
<p>
Semantic Cache for Large Language Models.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
name
</strong>
(
<em>
str
</em>
<em>
,
</em>
<em>
optional
</em>
) β The name of the semantic cache search index.
Defaults to βllmcacheβ.
</li>
<li>
<strong>
prefix
</strong>
(
<em>
Optional
</em>
*[*
<em>
str
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The prefix for Redis keys
associated with the semantic cache search index. Defaults to
None, and the index name will be used as the key prefix.
</li>
<li>
<strong>
distance_threshold
</strong>
(
<em>
float
</em>
<em>
,
</em>
<em>
optional
</em>
) β Semantic threshold for the
cache. Defaults to 0.1.
</li>
<li>
<strong>
ttl
</strong>
(
<em>
Optional
</em>
*[*
<em>
int
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The time-to-live for records cached
in Redis. Defaults to None.
</li>
<li>
<strong>
vectorizer
</strong>
(
<em>
BaseVectorizer
</em>
<em>
,
</em>
<em>
optional
</em>
) β The vectorizer for the cache.
Defaults to HFTextVectorizer.
</li>
<li>
<strong>
redis_client
</strong>
(
<em>
Redis
</em>
<em>
,
</em>
<em>
optional
</em>
) β A redis client connection instance.
Defaults to None.
</li>
<li>
<strong>
redis_url
</strong>
(
<em>
str
</em>
<em>
,
</em>
<em>
optional
</em>
) β The redis url. Defaults to
βredis://localhost:6379β.
</li>
<li>
<strong>
connection_args
</strong>
(
<em>
Dict
</em>
*[*
<em>
str
</em>
<em>
,
</em>
<em>
Any
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The connection arguments
for the redis client. Defaults to None.
</li>
</ul>
</li>
<li>
<strong>
Raises:
</strong>
<ul>
<li>
<strong>
TypeError
</strong>
β If an invalid vectorizer is provided.
</li>
<li>
<strong>
TypeError
</strong>
β If the TTL value is not an int.
</li>
<li>
<strong>
ValueError
</strong>
β If the threshold is not between 0 and 1.
</li>
<li>
<strong>
ValueError
</strong>
β If the index name is not provided
</li>
</ul>
</li>
</ul>
<h3 id="checkpromptnone-vectornone-num_results1-return_fieldsnone">
check(prompt=None, vector=None, num_results=1, return_fields=None)
</h3>
<p>
Checks the semantic cache for results similar to the specified prompt
or vector.
</p>
<p>
This method searches the cache using vector similarity with
either a raw text prompt (converted to a vector) or a provided vector as
input. It checks for semantically similar prompts and fetches the cached
LLM responses.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
prompt
</strong>
(
<em>
Optional
</em>
*[*
<em>
str
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The text prompt to search for in
the cache.
</li>
<li>
<strong>
vector
</strong>
(
<em>
Optional
</em>
*[*
<em>
List
</em>
*[*
<em>
float
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The vector representation
of the prompt to search for in the cache.
</li>
<li>
<strong>
num_results
</strong>
(
<em>
int
</em>
<em>
,
</em>
<em>
optional
</em>
) β The number of cached results to return.
Defaults to 1.
</li>
<li>
<strong>
return_fields
</strong>
(
<em>
Optional
</em>
*[*
<em>
List
</em>
*[*
<em>
str
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The fields to include
in each returned result. If None, defaults to all available
fields in the cached entry.
</li>
</ul>
</li>
<li>
<dl>
<dt>
<strong>
Returns:
</strong>
</dt>
<dt>
A list of dicts containing the requested
</dt>
<dd>
return fields for each similar cached response.
</dd>
</dl>
</li>
<li>
<strong>
Return type:
</strong>
List[Dict[str, Any]]
</li>
<li>
<strong>
Raises:
</strong>
<ul>
<li>
<strong>
ValueError
</strong>
β If neither a prompt nor a vector is specified.
</li>
<li>
<strong>
TypeError
</strong>
β If return_fields is not a list when provided.
</li>
</ul>
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">response</span> <span class="o">=</span> <span class="n">cache</span><span class="o">.</span><span class="n">check</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">prompt</span><span class="o">=</span><span class="s2">"What is the captial city of France?"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="clear">
clear()
</h3>
<p>
Clear the cache of all keys while preserving the index.
</p>
<ul>
<li>
<strong>
Return type:
</strong>
None
</li>
</ul>
<h3 id="delete">
delete()
</h3>
<p>
Clear the semantic cache of all keys and remove the underlying search
index.
</p>
<ul>
<li>
<strong>
Return type:
</strong>
None
</li>
</ul>
<h3 id="deserializemetadata">
deserialize(metadata)
</h3>
<p>
Deserialize the input from a string.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
metadata
</strong>
(
<em>
str
</em>
) β
</li>
<li>
<strong>
Return type:
</strong>
<em>
Dict
</em>
[str,
<em>
Any
</em>
]
</li>
</ul>
<h3 id="hash_inputprompt">
hash_input(prompt)
</h3>
<p>
Hashes the input using SHA256.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
prompt
</strong>
(
<em>
str
</em>
) β
</li>
</ul>
<h3 id="serializemetadata">
serialize(metadata)
</h3>
<p>
Serlize the input into a string.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
metadata
</strong>
(
<em>
Dict
</em>
*[*
<em>
str
</em>
<em>
,
</em>
<em>
Any
</em>
<em>
]
</em>
) β
</li>
<li>
<strong>
Return type:
</strong>
str
</li>
</ul>
<h3 id="set_thresholddistance_threshold">
set_threshold(distance_threshold)
</h3>
<p>
Sets the semantic distance threshold for the cache.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
distance_threshold
</strong>
(
<em>
float
</em>
) β The semantic distance threshold for
the cache.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
ValueError
</strong>
β If the threshold is not between 0 and 1.
</li>
<li>
<strong>
Return type:
</strong>
None
</li>
</ul>
<h3 id="set_ttlttlnone">
set_ttl(ttl=None)
</h3>
<p>
Set the default TTL, in seconds, for entries in the cache.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
ttl
</strong>
(
<em>
Optional
</em>
*[*
<em>
int
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The optional time-to-live expiration
for the cache, in seconds.
</li>
<li>
<strong>
Raises:
</strong>
<strong>
ValueError
</strong>
β If the time-to-live value is not an integer.
</li>
</ul>
<h3 id="set_vectorizervectorizer">
set_vectorizer(vectorizer)
</h3>
<p>
Sets the vectorizer for the LLM cache.
</p>
<p>
Must be a valid subclass of BaseVectorizer and have equivalent
dimensions to the vector field defined in the schema.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<strong>
vectorizer
</strong>
(
<em>
BaseVectorizer
</em>
) β The RedisVL vectorizer to use for
vectorizing cache entries.
</li>
<li>
<strong>
Raises:
</strong>
<ul>
<li>
<strong>
TypeError
</strong>
β If the vectorizer is not a valid type.
</li>
<li>
<strong>
ValueError
</strong>
β If the vector dimensions are mismatched.
</li>
</ul>
</li>
<li>
<strong>
Return type:
</strong>
None
</li>
</ul>
<h3 id="storeprompt-response-vectornone-metadatanone">
store(prompt, response, vector=None, metadata=None)
</h3>
<p>
Stores the specified key-value pair in the cache along with metadata.
</p>
<ul>
<li>
<strong>
Parameters:
</strong>
<ul>
<li>
<strong>
prompt
</strong>
(
<em>
str
</em>
) β The user prompt to cache.
</li>
<li>
<strong>
response
</strong>
(
<em>
str
</em>
) β The LLM response to cache.
</li>
<li>
<strong>
vector
</strong>
(
<em>
Optional
</em>
*[*
<em>
List
</em>
*[*
<em>
float
</em>
<em>
]
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The prompt vector to
cache. Defaults to None, and the prompt vector is generated on
demand.
</li>
<li>
<strong>
metadata
</strong>
(
<em>
Optional
</em>
*[*
<em>
dict
</em>
<em>
]
</em>
<em>
,
</em>
<em>
optional
</em>
) β The optional metadata to cache
alongside the prompt and response. Defaults to None.
</li>
</ul>
</li>
<li>
<strong>
Returns:
</strong>
The Redis key for the entries added to the semantic cache.
</li>
<li>
<strong>
Return type:
</strong>
str
</li>
<li>
<strong>
Raises:
</strong>
<ul>
<li>
<strong>
ValueError
</strong>
β If neither prompt nor vector is specified.
</li>
<li>
<strong>
TypeError
</strong>
β If provided metadata is not a dictionary.
</li>
</ul>
</li>
</ul>
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="n">key</span> <span class="o">=</span> <span class="n">cache</span><span class="o">.</span><span class="n">store</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="n">prompt</span><span class="o">=</span><span class="s2">"What is the captial city of France?"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">response</span><span class="o">=</span><span class="s2">"Paris"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">metadata</span><span class="o">=</span><span class="p">{</span><span class="s2">"city"</span><span class="p">:</span> <span class="s2">"Paris"</span><span class="p">,</span> <span class="s2">"country"</span><span class="p">:</span> <span class="s2">"France"</span><span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span></code></pre>
</div>
<h3 id="property-distance_threshold--float">
<em>
property
</em>
distance_threshold
<em>
: float
</em>
</h3>
<p>
The semantic distance threshold for the cache.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The semantic distance threshold.
</li>
<li>
<strong>
Return type:
</strong>
float
</li>
</ul>
<h3 id="property-index--searchindexsearchindexmdredisvlindexsearchindex">
<em>
property
</em>
index
<em>
:
<a href="searchindex.md#redisvl.index.SearchIndex">
SearchIndex
</a>
</em>
</h3>
<p>
The underlying SearchIndex for the cache.
</p>
<ul>
<li>
<strong>
Returns:
</strong>
The search index.
</li>
<li>
<strong>
Return type:
</strong>
<a href="searchindex.md#redisvl.index.SearchIndex">
SearchIndex
</a>
</li>
</ul>
<h3 id="property-ttl--int--none">
<em>
property
</em>
ttl
<em>
: int | None
</em>
</h3>
<p>
The default TTL, in seconds, for entries in the cache.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redisvl/api/cache/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/cluster-help/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CLUSTER HELP
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CLUSTER HELP</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
5.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The
<code>
CLUSTER HELP
</code>
command returns a helpful text describing the different subcommands.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: a list of subcommands and their descriptions.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cluster-help/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/cf.scandump.html | <section class="prose w-full py-12">
<h1 class="command-name">
CF.SCANDUMP
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CF.SCANDUMP key iterator</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(n), where n is the capacity
</dd>
</dl>
<p>
Begins an incremental save of the cuckoo filter.
</p>
<p>
This command is useful for large cuckoo filters that cannot fit into the
<a href="/docs/latest/commands/dump/">
<code>
DUMP
</code>
</a>
and
<a href="/docs/latest/commands/restore/">
<code>
RESTORE
</code>
</a>
model.
</p>
<p>
The first time this command is called, the value of
<code>
iter
</code>
should be 0.
</p>
<p>
This command returns successive
<code>
(iter, data)
</code>
pairs until
<code>
(0, NULL)
</code>
indicates completion.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for a cuckoo filter to save.
</p>
</details>
<details open="">
<summary>
<code>
iterator
</code>
</summary>
<p>
Iterator value; either 0 or the iterator from a previous invocation of this command
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
Returns one of these replies:
</p>
<ul>
<li>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
of
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
(
<em>
Iterator
</em>
) and [] (
<em>
Data
</em>
).
</p>
<p>
The Iterator is passed as input to the next invocation of
<code>
CF.SCANDUMP
</code>
. If
<em>
Iterator
</em>
is 0, then it means iteration has completed.
</p>
<p>
The iterator-data pair should also be passed to
<a href="/docs/latest/commands/cf.loadchunk/">
<code>
CF.LOADCHUNK
</code>
</a>
when restoring the filter.
</p>
</li>
<li>
<p>
[] on error (invalid arguments, key not found, wrong key type, etc.)
</p>
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> CF.RESERVE cf <span class="m">8</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> CF.ADD cf item1
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">redis> CF.SCANDUMP cf <span class="m">0</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"\x01\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00\x01\x008\x9a\xe0\xd8\xc3\x7f\x00\x00"</span>
</span></span><span class="line"><span class="cl">redis> CF.SCANDUMP cf <span class="m">1</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">9</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="s2">"\x00\x00\x00\x00\a\x00\x00\x00"</span>
</span></span><span class="line"><span class="cl">redis> CF.SCANDUMP cf <span class="m">9</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span>
</span></span><span class="line"><span class="cl">redis> DEL bf
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">redis> CF.LOADCHUNK cf <span class="m">1</span> <span class="s2">"\x01\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14\x00\x01\x008\x9a\xe0\xd8\xc3\x7f\x00\x00"</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> CF.LOADCHUNK cf <span class="m">9</span> <span class="s2">"\x00\x00\x00\x00\a\x00\x00\x00"</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> CF.EXISTS cf item1
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1</span></span></span></code></pre>
</div>
<p>
Python code:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">chunks</span> <span class="o">=</span> <span class="o">[]</span>
</span></span><span class="line"><span class="cl"><span class="nv">iter</span> <span class="o">=</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl"><span class="k">while</span> True:
</span></span><span class="line"><span class="cl"> iter, <span class="nv">data</span> <span class="o">=</span> CF.SCANDUMP<span class="o">(</span>key, iter<span class="o">)</span>
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nv">iter</span> <span class="o">==</span> 0:
</span></span><span class="line"><span class="cl"> <span class="nb">break</span>
</span></span><span class="line"><span class="cl"> <span class="k">else</span>:
</span></span><span class="line"><span class="cl"> chunks.append<span class="o">([</span>iter, data<span class="o">])</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Load it back</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> chunk in chunks:
</span></span><span class="line"><span class="cl"> iter, <span class="nv">data</span> <span class="o">=</span> chunk
</span></span><span class="line"><span class="cl"> CF.LOADCHUNK<span class="o">(</span>key, iter, data<span class="o">)</span></span></span></code></pre>
</div>
<p>
</p>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/cf.scandump/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/zadd/.html | <section class="prose w-full py-12">
<h1 class="command-name">
ZADD
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">ZADD key [NX | XX] [GT | LT] [CH] [INCR] score member [score member
...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
1.2.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(log(N)) for each item added, where N is the number of elements in the sorted set.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@sortedset
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Adds all the specified members with the specified scores to the sorted set
stored at
<code>
key
</code>
.
It is possible to specify multiple score / member pairs.
If a specified member is already a member of the sorted set, the score is
updated and the element reinserted at the right position to ensure the correct
ordering.
</p>
<p>
If
<code>
key
</code>
does not exist, a new sorted set with the specified members as sole
members is created, like if the sorted set was empty. If the key exists but does not hold a sorted set, an error is returned.
</p>
<p>
The score values should be the string representation of a double precision floating point number.
<code>
+inf
</code>
and
<code>
-inf
</code>
values are valid values as well.
</p>
<h2 id="zadd-options">
ZADD options
</h2>
<p>
ZADD supports a list of options, specified after the name of the key and before
the first score argument. Options are:
</p>
<ul>
<li>
<strong>
XX
</strong>
: Only update elements that already exist. Don't add new elements.
</li>
<li>
<strong>
NX
</strong>
: Only add new elements. Don't update already existing elements.
</li>
<li>
<strong>
LT
</strong>
: Only update existing elements if the new score is
<strong>
less than
</strong>
the current score. This flag doesn't prevent adding new elements.
</li>
<li>
<strong>
GT
</strong>
: Only update existing elements if the new score is
<strong>
greater than
</strong>
the current score. This flag doesn't prevent adding new elements.
</li>
<li>
<strong>
CH
</strong>
: Modify the return value from the number of new elements added, to the total number of elements changed (CH is an abbreviation of
<em>
changed
</em>
). Changed elements are
<strong>
new elements added
</strong>
and elements already existing for which
<strong>
the score was updated
</strong>
. So elements specified in the command line having the same score as they had in the past are not counted. Note: normally the return value of
<code>
ZADD
</code>
only counts the number of new elements added.
</li>
<li>
<strong>
INCR
</strong>
: When this option is specified
<code>
ZADD
</code>
acts like
<a href="/docs/latest/commands/zincrby/">
<code>
ZINCRBY
</code>
</a>
. Only one score-element pair can be specified in this mode.
</li>
</ul>
<p>
Note: The
<strong>
GT
</strong>
,
<strong>
LT
</strong>
and
<strong>
NX
</strong>
options are mutually exclusive.
</p>
<h2 id="range-of-integer-scores-that-can-be-expressed-precisely">
Range of integer scores that can be expressed precisely
</h2>
<p>
Redis sorted sets use a
<em>
double 64-bit floating point number
</em>
to represent the score. In all the architectures we support, this is represented as an
<strong>
IEEE 754 floating point number
</strong>
, that is able to represent precisely integer numbers between
<code>
-(2^53)
</code>
and
<code>
+(2^53)
</code>
included. In more practical terms, all the integers between -9007199254740992 and 9007199254740992 are perfectly representable. Larger integers, or fractions, are internally represented in exponential form, so it is possible that you get only an approximation of the decimal number, or of the very big integer, that you set as score.
</p>
<h2 id="sorted-sets-101">
Sorted sets 101
</h2>
<p>
Sorted sets are sorted by their score in an ascending way.
The same element only exists a single time, no repeated elements are
permitted. The score can be modified both by
<code>
ZADD
</code>
that will update the
element score, and as a side effect, its position on the sorted set, and
by
<a href="/docs/latest/commands/zincrby/">
<code>
ZINCRBY
</code>
</a>
that can be used in order to update the score relatively to its
previous value.
</p>
<p>
The current score of an element can be retrieved using the
<a href="/docs/latest/commands/zscore/">
<code>
ZSCORE
</code>
</a>
command,
that can also be used to verify if an element already exists or not.
</p>
<p>
For an introduction to sorted sets, see the data types page on
<a href="/develop/data-types#sorted-sets">
sorted
sets
</a>
.
</p>
<h2 id="elements-with-the-same-score">
Elements with the same score
</h2>
<p>
While the same element can't be repeated in a sorted set since every element
is unique, it is possible to add multiple different elements
<em>
having the same score
</em>
. When multiple elements have the same score, they are
<em>
ordered lexicographically
</em>
(they are still ordered by score as a first key, however, locally, all the elements with the same score are relatively ordered lexicographically).
</p>
<p>
The lexicographic ordering used is binary, it compares strings as array of bytes.
</p>
<p>
If the user inserts all the elements in a sorted set with the same score (for example 0), all the elements of the sorted set are sorted lexicographically, and range queries on elements are possible using the command
<a href="/docs/latest/commands/zrangebylex/">
<code>
ZRANGEBYLEX
</code>
</a>
(Note: it is also possible to query sorted sets by range of scores using
<a href="/docs/latest/commands/zrangebyscore/">
<code>
ZRANGEBYSCORE
</code>
</a>
).
</p>
<h2 id="examples">
Examples
</h2>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="cmds_sorted_set-stepzadd">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_cmds_sorted_set-stepzadd" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl">> ZADD myzset 1 "one"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD myzset 1 "uno"
</span></span><span class="line hl"><span class="cl">(integer) 1
</span></span><span class="line hl"><span class="cl">> ZADD myzset 2 "two" 3 "three"
</span></span><span class="line hl"><span class="cl">(integer) 2
</span></span><span class="line hl"><span class="cl">> ZRANGE myzset 0 -1 WITHSCORES
</span></span><span class="line hl"><span class="cl">1) "one"
</span></span><span class="line hl"><span class="cl">2) "1"
</span></span><span class="line hl"><span class="cl">3) "uno"
</span></span><span class="line hl"><span class="cl">4) "1"
</span></span><span class="line hl"><span class="cl">5) "two"
</span></span><span class="line hl"><span class="cl">6) "2"
</span></span><span class="line hl"><span class="cl">7) "three"
</span></span><span class="line hl"><span class="cl">8) "3"</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_cmds_sorted_set-stepzadd" title="Open example">
Python
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="s2">"localhost"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">6379</span><span class="p">,</span> <span class="n">db</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"one"</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"uno"</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 1</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"two"</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s2">"three"</span><span class="p">:</span> <span class="mi">3</span><span class="p">})</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> 2</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">withscores</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="c1"># >>> [('one', 1.0), ('uno', 1.0), ('two', 2.0), ('three', 3.0)]</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"one"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">:</span><span class="mi">2</span><span class="p">,</span> <span class="s2">"three"</span><span class="p">:</span><span class="mi">3</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> 3</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> ['one', 'two', 'three']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> ['three']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> ['two', 'three']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"one"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">:</span><span class="mi">2</span><span class="p">,</span> <span class="s2">"three"</span><span class="p">:</span><span class="mi">3</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">withscores</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> [('one', 1.0), ('two', 2.0)]</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zadd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">{</span><span class="s2">"one"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s2">"two"</span><span class="p">:</span><span class="mi">2</span><span class="p">,</span> <span class="s2">"three"</span><span class="p">:</span><span class="mi">3</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="n">res</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">zrange</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">byscore</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1"># >>> ['three']</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_cmds_sorted_set-stepzadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/cmds_sorted_set.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_cmds_sorted_set-stepzadd" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="nx">client</span><span class="p">.</span><span class="nx">on</span><span class="p">(</span><span class="s1">'error'</span><span class="p">,</span> <span class="nx">err</span> <span class="p">=></span> <span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="s1">'Redis Client Error'</span><span class="p">,</span> <span class="nx">err</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">().</span><span class="k">catch</span><span class="p">(</span><span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">val1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'one'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1</span> <span class="p">}]);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="c1">// returns 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">val2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'uno'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1</span> <span class="p">}]);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val2</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="c1">// returns 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">val3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'two'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">2</span> <span class="p">},</span> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'three'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">}]);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val3</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="c1">// returns 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">val4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val4</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="c1">// returns [{value: 'one', score: 1}, {value: 'uno', score: 1}, {value: 'two', score: 2}, {value: 'three', score: 3} ]
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'one'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'two'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">2</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'three'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val5</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'myzset'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns ['one', 'two', 'three']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'myzset'</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val7</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns ['three']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'myzset'</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val8</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns ['two', 'three']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val9</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'one'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'two'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">2</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'three'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val9</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val10</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRangeWithScores</span><span class="p">(</span><span class="s1">'myzset'</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns [{value: 'one', score: 1}, {value: 'two', score: 2}]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val11</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zAdd</span><span class="p">(</span><span class="s2">"myzset"</span><span class="p">,</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'one'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'two'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">2</span> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span> <span class="nx">value</span><span class="o">:</span> <span class="s1">'three'</span><span class="p">,</span> <span class="nx">score</span><span class="o">:</span> <span class="mi">3</span> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val11</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// returns 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">val12</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">zRange</span><span class="p">(</span><span class="s1">'myzset'</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="p">{</span> <span class="nx">BY</span><span class="o">:</span> <span class="s1">'SCORE'</span><span class="p">,</span> <span class="nx">LIMIT</span><span class="o">:</span> <span class="p">{</span> <span class="nx">offset</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">count</span><span class="o">:</span> <span class="mi">1</span> <span class="p">}</span> <span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">val12</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">// >>> ['three']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">quit</span><span class="p">();</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_cmds_sorted_set-stepzadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/cmds-sorted-set.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_cmds_sorted_set-stepzadd" title="Open example">
Java
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.HashMap</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Map</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.params.ZRangeParams</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.resps.Tuple</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">CmdsSortedSetExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzmpop' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzpopmax' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzpopmin' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">Double</span><span class="o">></span> <span class="n">zAddExampleParams</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"one"</span><span class="o">,</span> <span class="mf">1.0</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">zAddResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zAddExampleParams</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zAddResult1</span><span class="o">);</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"uno"</span><span class="o">,</span> <span class="mf">1.0</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">zAddResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zAddExampleParams</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zAddResult2</span><span class="o">);</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">clear</span><span class="o">();</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"two"</span><span class="o">,</span> <span class="mf">2.0</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">zAddExampleParams</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"three"</span><span class="o">,</span> <span class="mf">3.0</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">zAddResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zAddExampleParams</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zAddResult3</span><span class="o">);</span> <span class="c1">// >>> 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">zAddResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="k">new</span> <span class="n">ZRangeParams</span><span class="o">(</span><span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="n">Tuple</span> <span class="n">item</span><span class="o">:</span> <span class="n">zAddResult4</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Element: "</span> <span class="o">+</span> <span class="n">item</span><span class="o">.</span><span class="na">getElement</span><span class="o">()</span> <span class="o">+</span> <span class="s">", Score: "</span> <span class="o">+</span> <span class="n">item</span><span class="o">.</span><span class="na">getScore</span><span class="o">());</span>
</span></span><span class="line hl"><span class="cl"> <span class="o">}</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> Element: one, Score: 1.0
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Element: uno, Score: 1.0
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Element: two, Score: 2.0
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Element: three, Score: 3.0
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zadd' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zcard' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zcount' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zdiff' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zdiffstore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zincrby' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zinter' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zintercard' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zinterstore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zlexcount' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zmpop' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zmscore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zpopmax' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zpopmin' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrandmember' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">Double</span><span class="o">></span> <span class="n">zRangeExampleParams1</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"one"</span><span class="o">,</span> <span class="mf">1.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"two"</span><span class="o">,</span> <span class="mf">2.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams1</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"three"</span><span class="o">,</span> <span class="mf">3.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zRangeExampleParams1</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zRangeResult1</span><span class="o">);</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">zRangeResult2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="k">new</span> <span class="n">ZRangeParams</span><span class="o">(</span><span class="mi">0</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">join</span><span class="o">(</span><span class="s">", "</span><span class="o">,</span> <span class="n">zRangeResult2</span><span class="o">));</span> <span class="c1">// >>> one, two, three
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">zRangeResult3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="k">new</span> <span class="n">ZRangeParams</span><span class="o">(</span><span class="mi">2</span><span class="o">,</span> <span class="mi">3</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">join</span><span class="o">(</span><span class="s">", "</span><span class="o">,</span> <span class="n">zRangeResult3</span><span class="o">));</span> <span class="c1">// >> three
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">zRangeResult4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrange</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="k">new</span> <span class="n">ZRangeParams</span><span class="o">(-</span><span class="mi">2</span><span class="o">,</span> <span class="o">-</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">join</span><span class="o">(</span><span class="s">", "</span><span class="o">,</span> <span class="n">zRangeResult4</span><span class="o">));</span> <span class="c1">// >> two, three
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange1' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">Double</span><span class="o">></span> <span class="n">zRangeExampleParams2</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"one"</span><span class="o">,</span> <span class="mf">1.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"two"</span><span class="o">,</span> <span class="mf">2.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams2</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"three"</span><span class="o">,</span> <span class="mf">3.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zRangeExampleParams2</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zRangeResult5</span><span class="o">);</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">Tuple</span><span class="o">></span> <span class="n">zRangeResult6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeWithScores</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="k">new</span> <span class="n">ZRangeParams</span><span class="o">(</span><span class="mi">0</span><span class="o">,</span> <span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">for</span> <span class="o">(</span><span class="n">Tuple</span> <span class="n">item</span><span class="o">:</span> <span class="n">zRangeResult6</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">"Element: "</span> <span class="o">+</span> <span class="n">item</span><span class="o">.</span><span class="na">getElement</span><span class="o">()</span> <span class="o">+</span> <span class="s">", Score: "</span> <span class="o">+</span> <span class="n">item</span><span class="o">.</span><span class="na">getScore</span><span class="o">());</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> Element: one, Score: 1.0
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// >>> Element: two, Score: 2.0
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange2' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Map</span><span class="o"><</span><span class="n">String</span><span class="o">,</span> <span class="n">Double</span><span class="o">></span> <span class="n">zRangeExampleParams3</span> <span class="o">=</span> <span class="k">new</span> <span class="n">HashMap</span><span class="o"><>();</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"one"</span><span class="o">,</span> <span class="mf">1.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"two"</span><span class="o">,</span> <span class="mf">2.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">zRangeExampleParams3</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="s">"three"</span><span class="o">,</span> <span class="mf">3.0</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zadd</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="n">zRangeExampleParams3</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">zRangeResult7</span><span class="o">);</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">zRangeResult8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">zrangeByScore</span><span class="o">(</span><span class="s">"myzset"</span><span class="o">,</span> <span class="s">"(1"</span><span class="o">,</span> <span class="s">"+inf"</span><span class="o">,</span> <span class="mi">1</span><span class="o">,</span> <span class="mi">1</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">String</span><span class="o">.</span><span class="na">join</span><span class="o">(</span><span class="s">", "</span><span class="o">,</span> <span class="n">zRangeResult8</span><span class="o">));</span> <span class="c1">// >>> three
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange3' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangebylex' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangebyscore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangestore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrank' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrem' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebylex' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebyrank' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebyscore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrange' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrangebylex' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrangebyscore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrank' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zscan' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zscore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zunion' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zunionstore' step.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_cmds_sorted_set-stepzadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/CmdsSortedSetExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_cmds_sorted_set-stepzadd" title="Open example">
Go
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_zadd_cmd</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">zAddResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"one"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zAddResult1</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">zAddResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"uno"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zAddResult2</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">zAddResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"two"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">2</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"three"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">3</span><span class="p">},</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zAddResult3</span><span class="p">)</span> <span class="c1">// >>> 2
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">zAddResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zAddResult4</span><span class="p">)</span> <span class="c1">// >>> [{1 one} {1 uno} {2 two} {3 three}]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_zrange1</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">zrangeResult1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"one"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"two"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">2</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"three"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">3</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zrangeResult1</span><span class="p">)</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">zrangeResult2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zrangeResult2</span><span class="p">)</span> <span class="c1">// >>> [one two three]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">zrangeResult3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zrangeResult3</span><span class="p">)</span> <span class="c1">// >>> [three]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">zrangeResult4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRange</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span> <span class="o">-</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zrangeResult4</span><span class="p">)</span> <span class="c1">// >>> [two three]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_zrange2</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">zRangeResult5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"one"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"two"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">2</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"three"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">3</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zRangeResult5</span><span class="p">)</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">zRangeResult6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRangeWithScores</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zRangeResult6</span><span class="p">)</span> <span class="c1">// >>> [{1 one} {2 two}]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_zrange3</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">zRangeResult7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZAdd</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"one"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">1</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"two"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">2</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">Z</span><span class="p">{</span><span class="nx">Member</span><span class="p">:</span> <span class="s">"three"</span><span class="p">,</span> <span class="nx">Score</span><span class="p">:</span> <span class="mi">3</span><span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zRangeResult7</span><span class="p">)</span> <span class="c1">// >>> 3
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">zRangeResult8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">ZRangeArgs</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">redis</span><span class="p">.</span><span class="nx">ZRangeArgs</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Key</span><span class="p">:</span> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ByScore</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Start</span><span class="p">:</span> <span class="s">"(1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Stop</span><span class="p">:</span> <span class="s">"+inf"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Offset</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Count</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">zRangeResult8</span><span class="p">)</span> <span class="c1">// >>> [three]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_cmds_sorted_set-stepzadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/cmds_sorted_set_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_cmds_sorted_set-stepzadd" name="cmds_sorted_set-stepzadd" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_cmds_sorted_set-stepzadd" title="Open example">
C#
</label>
<div aria-labelledby="tab-cmds_sorted_set-stepzadd" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_cmds_sorted_set-stepzadd" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">NRedisStack.Tests</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="k">using</span> <span class="nn">StackExchange.Redis</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">CmdsSortedSet</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">muxer</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">muxer</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzmpop' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzpopmax' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'bzpopmin' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">zAddResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="s">"one"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">zAddResult1</span><span class="p">);</span> <span class="c1">// >>> True</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">bool</span> <span class="n">zAddResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="s">"uno"</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">zAddResult2</span><span class="p">);</span> <span class="c1">// >>> True</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">long</span> <span class="n">zAddResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span>
</span></span><span class="line hl"><span class="cl"> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"two"</span><span class="p">,</span> <span class="m">2</span><span class="p">),</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"three"</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">zAddResult3</span><span class="p">);</span> <span class="c1">// >>> 2</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">zAddResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", zAddResult4.Select(b => $"</span><span class="p">{</span><span class="n">b</span><span class="p">.</span><span class="n">Element</span><span class="p">}:</span> <span class="p">{</span><span class="n">b</span><span class="p">.</span><span class="n">Score</span><span class="p">}</span><span class="s">"))}"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="c1">// >>> one: 1, uno: 1, two: 2, three: 3</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zadd' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zcard' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zcount' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zdiff' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zdiffstore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zincrby' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zinter' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zintercard' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zinterstore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zlexcount' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zmpop' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zmscore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zpopmax' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zpopmin' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrandmember' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"one"</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"two"</span><span class="p">,</span> <span class="m">2</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"three"</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">zRangeResult1</span><span class="p">);</span> <span class="c1">// >>> 3</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">zRangeResult2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">zRangeResult2</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> one, two, three</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">zRangeResult3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="m">2</span><span class="p">,</span> <span class="m">3</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">zRangeResult3</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> three</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">zRangeResult4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRank</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="p">-</span><span class="m">2</span><span class="p">,</span> <span class="p">-</span><span class="m">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">zRangeResult4</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> two, three</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange1' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"one"</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"two"</span><span class="p">,</span> <span class="m">2</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"three"</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="n">zRangeResult6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByRankWithScores</span><span class="p">(</span><span class="s">"myzset"</span><span class="p">,</span> <span class="m">0</span><span class="p">,</span> <span class="m">1</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="s">$"{string.Join("</span><span class="p">,</span> <span class="s">", zRangeResult6.Select(b => $"</span><span class="p">{</span><span class="n">b</span><span class="p">.</span><span class="n">Element</span><span class="p">}:</span> <span class="p">{</span><span class="n">b</span><span class="p">.</span><span class="n">Score</span><span class="p">}</span><span class="s">"))}"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> one: 1, two: 2</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange2' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">long</span> <span class="n">zRangeResult7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetAdd</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">[]</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"one"</span><span class="p">,</span> <span class="m">1</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"two"</span><span class="p">,</span> <span class="m">2</span><span class="p">),</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="n">SortedSetEntry</span><span class="p">(</span><span class="s">"three"</span><span class="p">,</span> <span class="m">3</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">RedisValue</span><span class="p">[]</span> <span class="n">zRangeResult8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">SortedSetRangeByScore</span><span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"myzset"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="m">1</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="kt">double</span><span class="p">.</span><span class="n">PositiveInfinity</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">Exclude</span><span class="p">.</span><span class="n">Start</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="n">skip</span><span class="p">:</span> <span class="m">1</span><span class="p">,</span> <span class="n">take</span><span class="p">:</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl"> <span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="kt">string</span><span class="p">.</span><span class="n">Join</span><span class="p">(</span><span class="s">", "</span><span class="p">,</span> <span class="n">zRangeResult8</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="c1">// >>> three</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrange3' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangebylex' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangebyscore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrangestore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrank' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrem' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebylex' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebyrank' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zremrangebyscore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrange' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrangebylex' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrangebyscore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zrevrank' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zscan' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zscore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zunion' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="c1">// Tests for 'zunionstore' step.</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_cmds_sorted_set-stepzadd')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_cmds_sorted_set-stepzadd" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/CmdsSortedSetExamples.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
Give these commands a try in the interactive console:
</p>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 1 "uno"
(integer) 1
redis> ZADD myzset 2 "two" 3 "three"
(integer) 2
redis> ZRANGE myzset 0 -1 WITHSCORES
1) "one"
2) "1"
3) "uno"
4) "1"
5) "two"
6) "2"
7) "three"
8) "3"
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<p>
Any of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Nil reply
</a>
: if the operation was aborted because of a conflict with one of the
<em>
XX/NX/LT/GT
</em>
options.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of new members when the
<em>
CH
</em>
option is not used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of new or updated members when the
<em>
CH
</em>
option is used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the updated score of the member when the
<em>
INCR
</em>
option is used.
</li>
</ul>
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<p>
Any of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#nulls">
Null reply
</a>
: if the operation was aborted because of a conflict with one of the
<em>
XX/NX/LT/GT
</em>
options.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of new members when the
<em>
CH
</em>
option is not used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of new or updated members when the
<em>
CH
</em>
option is used.
</li>
<li>
<a href="../../develop/reference/protocol-spec#doubles">
Double reply
</a>
: the updated score of the member when the
<em>
INCR
</em>
option is used.
</li>
</ul>
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 2.4.0: Accepts multiple elements.
</li>
<li>
Starting with Redis version 3.0.2: Added the
<code>
XX
</code>
,
<code>
NX
</code>
,
<code>
CH
</code>
and
<code>
INCR
</code>
options.
</li>
<li>
Starting with Redis version 6.2.0: Added the
<code>
GT
</code>
and
<code>
LT
</code>
options.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zadd/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/shard/sync/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Sync object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the sync object used with Redis Enterprise Software REST API calls.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
progress
</td>
<td>
integer
</td>
<td>
Number of bytes remaining in current sync
</td>
</tr>
<tr>
<td>
status
</td>
<td>
'in_progress'
<br/>
'idle'
<br/>
'link_down'
</td>
<td>
Indication of the shard's current sync status
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/shard/sync/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/security/access-control/manage-users/default-user/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage default user
</h1>
<p class="text-lg -mt-5 mb-10">
Manage a database's default user.
</p>
<p>
When you
<a href="/docs/latest/operate/rs/7.4/databases/create/">
create a database
</a>
, default user database access is enabled by default (
<strong>
Unauthenticated access
</strong>
is selected). This gives the default user full access to the database and enables compatibility with versions of Redis before Redis 6.
</p>
<p>
Select
<strong>
Password-only authentication
</strong>
, then enter and confirm a default database password to require authentication for connections to the database.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-access-control-password-only.png" sdata-lightbox="/images/rs/screenshots/databases/security-access-control-password-only.png">
<img alt="Select Password-only authentication to require a password to access the database." src="/docs/latest/images/rs/screenshots/databases/security-access-control-password-only.png"/>
</a>
<h2 id="authenticate-as-default-user">
Authenticate as default user
</h2>
<p>
When you configure a password for your database, all connections to the database must authenticate using the
<a href="/docs/latest/commands/auth/">
AUTH
</a>
command. See Redis security's
<a href="/docs/latest/operate/oss_and_stack/management/security/#authentication">
authentication
</a>
section for more information.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">AUTH <default-database-password>
</span></span></code></pre>
</div>
<h2 id="change-default-database-password">
Change default database password
</h2>
<p>
To change the default user's password:
</p>
<ol>
<li>
<p>
From the database's
<strong>
Security
</strong>
tab, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
Access Control
</strong>
section, select
<strong>
Password-only authentication
</strong>
as the
<strong>
Access method
</strong>
.
</p>
</li>
<li>
<p>
Enter and re-enter the new password.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h2 id="deactivate-default-user">
Deactivate default user
</h2>
<p>
If you set up
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
role-based access control
</a>
with
<a href="/docs/latest/operate/rs/7.4/security/access-control/create-db-roles/">
access control lists
</a>
(ACLs) for your database and don't require backwards compatibility with versions earlier than Redis 6, you can
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-users/default-user/">
deactivate the default user
</a>
.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Warning:
</div>
Before you deactivate default user access, make sure the role associated with the database is
<a href="/docs/latest/operate/rs/7.4/security/access-control/create-users/">
assigned to a user
</a>
. Otherwise, the database will be inaccessible.
</div>
</div>
<p>
To deactivate the default user:
</p>
<ol>
<li>
<p>
From the database's
<strong>
Security
</strong>
tab, select
<strong>
Edit
</strong>
.
</p>
</li>
<li>
<p>
In the
<strong>
Access Control
</strong>
section, select
<strong>
Using ACL only
</strong>
as the
<strong>
Access method
</strong>
.
</p>
<a href="/docs/latest/images/rs/screenshots/databases/security-access-control-acl-only.png" sdata-lightbox="/images/rs/screenshots/databases/security-access-control-acl-only.png">
<img alt="Select Using ACL only to deactivate default user access to the database." src="/docs/latest/images/rs/screenshots/databases/security-access-control-acl-only.png"/>
</a>
</li>
<li>
<p>
Choose at least one role and Redis ACL to access the database.
</p>
</li>
<li>
<p>
Select
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/security/access-control/manage-users/default-user/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/active-active/create-reaadb/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Create Active-Active database (REAADB)
</h1>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
This feature is supported for general availability in releases 6.4.2-6 and later. Some of these features were available as a preview in 6.4.2-4 and 6.4.2-5. Please upgrade to 6.4.2-6 for the full set of general availability features and bug fixes.
</div>
</div>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
To create an Active-Active database, make sure you've completed all the following steps and have gathered the information listed below each step.
</p>
<ol>
<li>
<p>
Configure the
<a href="/docs/latest/operate/kubernetes/deployment/quick-start/#enable-the-admission-controller/">
admission controller and ValidatingWebhook
</a>
.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
These are installed and enabled by default on clusters created via the OpenShift OperatorHub.
</div>
</div>
<p>
</p>
</li>
<li>
<p>
Create two or more
<a href="/docs/latest/operate/kubernetes/deployment/quick-start/#create-a-redis-enterprise-cluster-rec">
RedisEnterpriseCluster (REC) custom resources
</a>
with enough
<a href="/docs/latest/operate/rs/installing-upgrading/install/plan-deployment/hardware-requirements/">
memory resources
</a>
.
</p>
<ul>
<li>
Name of each REC (
<code>
<rec-name>
</code>
)
</li>
<li>
Namespace for each REC (
<code>
<rec-namespace>
</code>
)
</li>
</ul>
</li>
<li>
<p>
Configure the REC
<a href="/docs/latest/operate/kubernetes/networking/ingressorroutespec/">
<code>
ingressOrRoutes
</code>
field
</a>
and
<a href="/docs/latest/operate/kubernetes/networking/ingressorroutespec/#configure-dns/">
create DNS records
</a>
.
</p>
<ul>
<li>
REC API hostname (
<code>
api-<rec-name>-<rec-namespace>.<subdomain>
</code>
)
</li>
<li>
Database hostname suffix (
<code>
-db-<rec-name>-<rec-namespace>.<subdomain>
</code>
)
</li>
</ul>
</li>
<li>
<p>
<a href="/docs/latest/operate/kubernetes/active-active/prepare-clusters/">
Prepare participating clusters
</a>
</p>
<ul>
<li>
RERC name (
<code>
<rerc-name
</code>
>)
</li>
<li>
RERC secret name (
<code>
redis-enterprise-<rerc-name>
</code>
)
</li>
</ul>
</li>
</ol>
<p>
For a list of example values used throughout this article, see the
<a href="#example-values">
Example values
</a>
section.
</p>
<h2 id="create-rerc">
Create
<code>
RedisEnterpriseRemoteCluster
</code>
resources
</h2>
<ol>
<li>
<p>
Create a
<code>
RedisEnterpriseRemoteCluster
</code>
(RERC) custom resource file for each participating Redis Enterprise cluster (REC).
</p>
<p>
Below are examples of RERC resources for two participating clusters. Substitute your own values to create your own resource.
</p>
<p>
Example RERC (
<code>
rerc-ohare
</code>
) for the REC named
<code>
rec-chicago
</code>
in the namespace
<code>
ns-illinois
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseRemoteCluster</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">rerc-ohare</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">recName</span><span class="p">:</span><span class="w"> </span><span class="l">rec-chicago</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">recNamespace</span><span class="p">:</span><span class="w"> </span><span class="l">ns-illinois</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">apiFqdnUrl</span><span class="p">:</span><span class="w"> </span><span class="l">api-rec-chicago-ns-illinois.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">dbFqdnSuffix</span><span class="p">:</span><span class="w"> </span>-<span class="l">db-rec-chicago-ns-illinois.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">secretName</span><span class="p">:</span><span class="w"> </span><span class="l">redis-enterprise-rerc-ohare</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
Example RERC (
<code>
rerc-raegan
</code>
) for the REC named
<code>
rec-arlington
</code>
in the namespace
<code>
ns-virginia
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseRemoteCluster</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">rerc-reagan</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">recName</span><span class="p">:</span><span class="w"> </span><span class="l">rec-arlington</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">recNamespace</span><span class="p">:</span><span class="w"> </span><span class="l">ns-virginia</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">apiFqdnUrl</span><span class="p">:</span><span class="w"> </span><span class="l">test-example-api-rec-arlington-ns-virginia.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">dbFqdnSuffix</span><span class="p">:</span><span class="w"> </span>-<span class="l">example-cluster-rec-arlington-ns-virginia.example.com</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">secretName</span><span class="p">:</span><span class="w"> </span><span class="l">redis-enterprise-rerc-reagan</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
For more details on RERC fields, see the
<a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_remote_cluster_api/">
RERC API reference
</a>
.
</p>
</li>
<li>
<p>
Create a Redis Enterprise remote cluster from each RERC custom resource file.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl create -f <rerc-file>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Check the status of your RERC. If
<code>
STATUS
</code>
is
<code>
Active
</code>
and
<code>
SPEC STATUS
</code>
is
<code>
Valid
</code>
, then your configurations are correct.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get rerc <rerc-name>
</span></span></code></pre>
</div>
<p>
The output should look similar to:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get rerc rerc-ohare
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">NAME STATUS SPEC STATUS LOCAL
</span></span><span class="line"><span class="cl">rerc-ohare Active Valid <span class="nb">true</span>
</span></span></code></pre>
</div>
<p>
In case of errors, review the RERC custom resource events and the Redis Enterprise operator logs.
</p>
</li>
</ol>
<h2 id="create-reaadb">
Create
<code>
RedisEnterpriseActiveActiveDatabase
</code>
resource
</h2>
<ol>
<li>
<p>
Create a
<code>
RedisEnterpriseActiveActiveDatabase
</code>
(REAADB) custom resource file meeting the naming requirements and listing the names of the RERC custom resources created in the last step.
</p>
<p>
Naming requirements:
</p>
<ul>
<li>
less than 63 characters
</li>
<li>
contains only lowercase letters, numbers, or hyphens
</li>
<li>
starts with a letter
</li>
<li>
ends with a letter or digit
</li>
</ul>
<p>
Example REAADB named
<code>
reaadb-boeing
</code>
linked to the REC named
<code>
rec-chicago
</code>
with two participating clusters and a global database configuration with shard count set to 3:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">app.redislabs.com/v1alpha1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">RedisEnterpriseActiveActiveDatabase</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">reaadb-boeing</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">globalConfigurations</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">databaseSecretName</span><span class="p">:</span><span class="w"> </span><span class="l"><my-secret></span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">memorySize</span><span class="p">:</span><span class="w"> </span><span class="l">200MB</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">shardCount</span><span class="p">:</span><span class="w"> </span><span class="m">3</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">participatingClusters</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">rerc-ohare</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">rerc-reagan</span><span class="w">
</span></span></span></code></pre>
</div>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Sharding is disabled on Active-Active databases created with a
<code>
shardCount
</code>
of 1. Sharding cannot be enabled after database creation.
</div>
</div>
<p>
For more details on RERC fields, see the
<a href="/docs/latest/operate/kubernetes/reference/redis_enterprise_remote_cluster_api/">
RERC API reference
</a>
.
</p>
</li>
<li>
<p>
Create a Redis Enterprise Active-Active database from the REAADB custom resource file.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl create -f <reaadb-file>
</span></span></code></pre>
</div>
</li>
<li>
<p>
Check the status of your RERC. If
<code>
STATUS
</code>
is
<code>
Active
</code>
and
<code>
SPEC STATUS
</code>
is
<code>
Valid
</code>
, your configurations are correct.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get reaadb <reaadb-name>
</span></span></code></pre>
</div>
<p>
The output should look similar to:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl get reaadb reaadb-boeing
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">NAME STATUS SPEC STATUS LINKED REDBS REPLICATION STATUS
</span></span><span class="line"><span class="cl">reaadb-boeing active Valid up
</span></span></code></pre>
</div>
<p>
In case of errors, review the REAADB custom resource events and the Redis Enterprise operator logs.
</p>
</li>
</ol>
<h2 id="example-values">
Example values
</h2>
<p>
This article uses the following example values:
</p>
<h4 id="example-cluster-1">
Example cluster 1
</h4>
<ul>
<li>
REC name:
<code>
rec-chicago
</code>
</li>
<li>
REC namespace:
<code>
ns-illinois
</code>
</li>
<li>
RERC name:
<code>
rerc-ohare
</code>
</li>
<li>
RERC secret name:
<code>
redis-enterprise-rerc-ohare
</code>
</li>
<li>
API FQDN:
<code>
api-rec-chicago-ns-illinois.example.com
</code>
</li>
<li>
DB FQDN suffix:
<code>
-db-rec-chicago-ns-illinois.example.com
</code>
</li>
</ul>
<h4 id="example-cluster-2">
Example cluster 2
</h4>
<ul>
<li>
REC name:
<code>
rec-arlington
</code>
</li>
<li>
REC namespace:
<code>
ns-virginia
</code>
</li>
<li>
RERC name:
<code>
rerc-raegan
</code>
</li>
<li>
RERC secret name:
<code>
redis-enterprise-rerc-reagan
</code>
</li>
<li>
API FQDN:
<code>
api-rec-arlington-ns-virginia.example.com
</code>
</li>
<li>
DB FQDN suffix:
<code>
-db-rec-arlington-ns-virginia.example.com
</code>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/active-active/create-reaadb/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/cluster/check/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Check all cluster nodes requests
</h1>
<p class="text-lg -mt-5 mb-10">
Requests that run checks on all cluster nodes.
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-cluster-check">
GET
</a>
</td>
<td>
<code>
/v1/cluster/check
</code>
</td>
<td>
Runs checks on all cluster nodes
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-check">
Check all nodes
</h2>
<pre><code>GET /v1/cluster/check
</code></pre>
<p>
Runs the following checks on all cluster nodes:
</p>
<table>
<thead>
<tr>
<th>
Check name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
bootstrap_status
</td>
<td>
Verifies the local node's bootstrap process completed without errors.
</td>
</tr>
<tr>
<td>
services
</td>
<td>
Verifies all Redis Enterprise Software services are running.
</td>
</tr>
<tr>
<td>
port_range
</td>
<td>
Verifies the
<a href="https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html">
<code>
ip_local_port_range
</code>
</a>
doesn't conflict with the ports Redis Enterprise might assign to shards.
</td>
</tr>
<tr>
<td>
pidfiles
</td>
<td>
Verifies all active local shards have PID files.
</td>
</tr>
<tr>
<td>
capabilities
</td>
<td>
Verifies all binaries have the proper capability bits.
</td>
</tr>
<tr>
<td>
existing_sockets
</td>
<td>
Verifies sockets exist for all processes that require them.
</td>
</tr>
<tr>
<td>
host_settings
</td>
<td>
Verifies the following:
<br/>
β’ Linux
<code>
overcommit_memory
</code>
setting is 1.
<br/>
β’
<code>
transparent_hugepage
</code>
is disabled.
<br/>
β’ Socket maximum connections setting
<code>
somaxconn
</code>
is 1024.
</td>
</tr>
<tr>
<td>
tcp_connectivity
</td>
<td>
Verifies this node can connect to all other alive nodes.
</td>
</tr>
</tbody>
</table>
<h4 id="required-permissions">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_all_nodes_checks">
view_all_nodes_checks
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /cluster/check
</code></pre>
<h4 id="request-headers">
Request headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Host
</td>
<td>
cnm.cluster.fqdn
</td>
<td>
Domain name
</td>
</tr>
<tr>
<td>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns a JSON array with results from all nodes.
</p>
<p>
When errors occur, the server returns a JSON object with
<code>
result: false
</code>
and an
<code>
error
</code>
field that provides additional information for each node that had an error. If an error occurs during a check, the
<code>
error
</code>
field only includes a message for the first check that fails on each node.
</p>
<p>
Possible
<code>
error
</code>
messages:
</p>
<ul>
<li>
"bootstrap request to cnm_http failed,resp_code: ...,resp_content: ..."
</li>
<li>
"process ... is not running or not responding (...)"
</li>
<li>
"could not communicate with 'supervisorctl': ..."
</li>
<li>
"connectivity check failed retrieving ports for testing"
</li>
</ul>
<h4 id="example-json-body">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"cluster_test_result"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"nodes"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"1"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"2"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</span><span class="p">:</span> <span class="kc">true</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"node_uid"</span><span class="p">:</span> <span class="s2">"3"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"result"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"error"</span><span class="p">:</span> <span class="s2">"process alert_mgr is not running or not responding ([Errno 111] Connection refused)"</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="https://www.rfc-editor.org/rfc/rfc9110.html#name-200-ok">
200 OK
</a>
</td>
<td>
No error
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/cluster/check/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/dump/.html | <section class="prose w-full py-12">
<h1 class="command-name">
DUMP
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">DUMP key</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.6.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) to access the key and additional O(N*M) to serialize it, where N is the number of Redis objects composing the value and M their average size. For small string values the time complexity is thus O(1)+O(1*M) where M is small, so simply O(1).
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@keyspace
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@read
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Serialize the value stored at key in a Redis-specific format and return it to
the user.
The returned value can be synthesized back into a Redis key using the
<a href="/docs/latest/commands/restore/">
<code>
RESTORE
</code>
</a>
command.
</p>
<p>
The serialization format is opaque and non-standard, however it has a few
semantic characteristics:
</p>
<ul>
<li>
It contains a 64-bit checksum that is used to make sure errors will be
detected.
The
<a href="/docs/latest/commands/restore/">
<code>
RESTORE
</code>
</a>
command makes sure to check the checksum before synthesizing a
key using the serialized value.
</li>
<li>
Values are encoded in the same format used by RDB.
</li>
<li>
An RDB version is encoded inside the serialized value, so that different Redis
versions with incompatible RDB formats will refuse to process the serialized
value.
</li>
</ul>
<p>
The serialized value does NOT contain expire information.
In order to capture the time to live of the current value the
<a href="/docs/latest/commands/pttl/">
<code>
PTTL
</code>
</a>
command
should be used.
</p>
<p>
If
<code>
key
</code>
does not exist a nil bulk reply is returned.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>> SET mykey 10
OK
> DUMP mykey
"\x00\xc0\n\n\x00n\x9fWE\x0e\xaec\xbb"
</code></pre>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: The serialized value of the key.
</li>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Nil reply
</a>
: the key does not exist.
</li>
</ul>
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the serialized value of the key.
</li>
<li>
<a href="../../develop/reference/protocol-spec#nulls">
Null reply
</a>
: the key does not exist.
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/dump/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/json.resp/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.RESP
<span class="text-base">
(deprecated)
</span>
</h1>
<div class="border-l-8 pl-4">
<p>
As of JSON version 2.6, this command is regarded as deprecated.
</p>
</div>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.RESP key [path]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/json">
JSON 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Return the JSON in
<code>
key
</code>
in
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
form
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key to parse.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
. This command uses the following mapping from JSON to RESP:
</p>
<ul>
<li>
JSON
<code>
null
</code>
maps to the bulk string reply.
</li>
<li>
JSON
<code>
false
</code>
and
<code>
true
</code>
values map to the simple string reply.
</li>
<li>
JSON number maps to the integer reply or bulk string reply, depending on type.
</li>
<li>
JSON string maps to the bulk string reply.
</li>
<li>
JSON array is represented as an array reply in which the first element is the simple string reply
<code>
[
</code>
, followed by the array's elements.
</li>
<li>
JSON object is represented as an array reply in which the first element is the simple string reply
<code>
{
</code>
. Each successive entry represents a key-value pair as a two-entry array reply of the bulk string reply.
</li>
</ul>
<p>
For more information about replies, see
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
</details>
<h2 id="return">
Return
</h2>
<p>
JSON.RESP returns an array reply specified as the JSON's RESP form detailed in
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Return an array of RESP details about a document
</b>
</summary>
<p>
Create a JSON document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET item:2 $ <span class="s1">'{"name":"Wireless earbuds","description":"Wireless Bluetooth in-ear headphones","connection":{"wireless":true,"type":"Bluetooth"},"price":64.99,"stock":17,"colors":["black","white"], "max_level":[80, 100, 120]}'</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Get all RESP details about the document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.RESP item:2
</span></span><span class="line"><span class="cl"> 1<span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"name"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"Wireless earbuds"</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"description"</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> <span class="s2">"Wireless Bluetooth in-ear headphones"</span>
</span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="s2">"connection"</span>
</span></span><span class="line"><span class="cl"> 7<span class="o">)</span> 1<span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"wireless"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="nb">true</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"type"</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> <span class="s2">"Bluetooth"</span>
</span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="s2">"price"</span>
</span></span><span class="line"><span class="cl"> 9<span class="o">)</span> <span class="s2">"64.989999999999995"</span>
</span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="s2">"stock"</span>
</span></span><span class="line"><span class="cl">11<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">17</span>
</span></span><span class="line"><span class="cl">12<span class="o">)</span> <span class="s2">"colors"</span>
</span></span><span class="line"><span class="cl">13<span class="o">)</span> 1<span class="o">)</span> <span class="o">[</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"black"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"white"</span>
</span></span><span class="line"><span class="cl">14<span class="o">)</span> <span class="s2">"max_level"</span>
</span></span><span class="line"><span class="cl">15<span class="o">)</span> 1<span class="o">)</span> <span class="o">[</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">80</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">100</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">120</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/json.set/">
<code>
JSON.SET
</code>
</a>
|
<a href="/docs/latest/commands/json.arrlen/">
<code>
JSON.ARRLEN
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/data-types/json/">
RedisJSON
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
Index and search JSON documents
</a>
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.resp/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/bloom/config/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Probabilistic data structure configuration compatibility with Redis Enterprise
</h1>
<p class="text-lg -mt-5 mb-10">
Probabilistic data structure configuration settings supported by Redis Enterprise Software and Redis Cloud.
</p>
<h2 id="configure-probabilistic-data-structures-in-redis-software">
Configure probabilistic data structures in Redis Software
</h2>
<p>
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
lets you manually change any
<a href="/docs/latest/develop/data-types/probabilistic/configuration/#redisbloom-configuration-parameters">
RedisBloom configuration setting
</a>
.
</p>
<p>
To change the RedisBloom configuration using the Redis Software Cluster Manager UI:
</p>
<ol>
<li>
<p>
From the
<strong>
Databases
</strong>
list, select the database, then click
<strong>
Configuration
</strong>
.
</p>
</li>
<li>
<p>
Select the
<strong>
Edit
</strong>
button.
</p>
</li>
<li>
<p>
In the
<strong>
Capabilities
</strong>
section, click
<strong>
Parameters
</strong>
.
</p>
</li>
<li>
<p>
After you finish editing the module's configuration parameters, click
<strong>
Done
</strong>
to close the parameter editor.
</p>
</li>
<li>
<p>
Click
<strong>
Save
</strong>
.
</p>
</li>
</ol>
<h2 id="configure-probabilistic-data-structures-in-redis-cloud">
Configure probabilistic data structures in Redis Cloud
</h2>
<p>
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
does not let you configure RedisBloom manually. However, if you have a Flexible or Annual
<a href="/docs/latest/operate/rc/subscriptions/">
subscription
</a>
, you can contact
<a href="https://redis.com/company/support/">
support
</a>
to request a configuration change. You cannot change RedisBloom configuration for Free or Fixed subscriptions.
</p>
<h2 id="configuration-settings">
Configuration settings
</h2>
<table>
<thead>
<tr>
<th style="text-align:left">
Setting
</th>
<th style="text-align:left">
Redis
<br/>
Enterprise
</th>
<th style="text-align:left">
Redis
<br/>
Cloud
</th>
<th style="text-align:left">
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/probabilistic/configuration/#cf_max_expansions">
CF_MAX_EXPANSIONS
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
β Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 32
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/probabilistic/configuration/#error_rate">
ERROR_RATE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
β Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 0.01
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/develop/data-types/probabilistic/configuration/#initial_size">
INITIAL_SIZE
</a>
</td>
<td style="text-align:left">
<span title="Supported">
β
Supported
</span>
<br/>
<span>
<br/>
</span>
</td>
<td style="text-align:left">
<span title="Supported">
β
Flexible & Annual
</span>
<br/>
<span title="Not supported">
<nobr>
β Free & Fixed
</nobr>
</span>
</td>
<td style="text-align:left">
Default: 100
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/bloom/config/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/release-notes/6-4-2-releases/6-4-2-8/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes release notes 6.4.2-8 (July 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
The Redis Enterprise K8s 6.4.2-8 release supports Redis Enterprise Software 6.4.2 and contains new features and feature improvements.
</p>
<h2 id="overview">
Overview
</h2>
<p>
Redis Enterprise for Kubernetes version 6.4.2-8 is a maintenance release of version 6.2.4-6. It includes critical bug fixes and an updated Redis Enterprise image.
</p>
<h2 id="new-in-this-release">
New in this release
</h2>
<h3 id="feature-enhancements">
Feature enhancements
</h3>
<ul>
<li>
New Redis Enterprise software version 6.4.2-94 (RED-105738)
</li>
</ul>
<h3 id="bug-fixes">
Bug fixes
</h3>
<ul>
<li>
Fixed bad handling of certificate chains in the REC controller (RED-105578)
</li>
</ul>
<h2 id="upgrade-considerations">
Upgrade considerations
</h2>
<p>
Be aware the following changes included in this release affect the upgrade process. Please read carefully before upgrading to 6.4.2-8.
</p>
<ul>
<li>
<p>
<strong>
ValidatingWebhookConfiguration
</strong>
</p>
<p>
This release uses a new
<code>
ValidatingWebhookConfiguration
</code>
resource to replace the
<code>
redb-admission
</code>
webhook resource. To use releases 6.4.2-4 or later, delete the old webhook resource and apply the new file. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#reapply-webhook">
upgrade Redis cluster
</a>
for instructions.
</p>
</li>
<li>
<p>
<strong>
OpenShift SCC
</strong>
</p>
<p>
This release includes a new SCC (
<code>
redis-enterprise-scc-v2
</code>
) that you need to bind to your service account before upgrading. OpenShift clusters running version 6.2.12 or earlier upgrading to version 6.2.18 or later might get stuck if you skip this step. See
<a href="/docs/latest/operate/kubernetes/upgrade/upgrade-redis-cluster/#before-upgrading">
upgrade a Redis Enterprise cluster (REC)
</a>
for expand.
</p>
</li>
</ul>
<h2 id="compatibility">
Compatibility
</h2>
<h3 id="deprecated-features">
Deprecated features
</h3>
<ul>
<li>
Support for Gesher, the advanced admission control configuration, is deprecated.
</li>
</ul>
<h3 id="supported-distributions">
Supported distributions
</h3>
<p>
The following table shows supported distributions at the time of this release. You can also find this list in
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
reflecting the most recent release.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
<strong>
Kubernetes version
</strong>
</th>
<th style="text-align:center">
1.22
</th>
<th style="text-align:center">
1.23
</th>
<th style="text-align:center">
1.24
</th>
<th style="text-align:center">
1.25
</th>
<th style="text-align:center">
1.26
</th>
<th style="text-align:center">
1.27
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
Community Kubernetes
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
</tr>
<tr>
<td style="text-align:left">
Amazon EKS
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
Azure AKS
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align:left">
Google GKE
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
Rancher 2.6
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
Rancher 2.7
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
VMware TKG 1.6
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
<strong>
OpenShift version
</strong>
</td>
<td style="text-align:center">
<strong>
4.9
</strong>
</td>
<td style="text-align:center">
<strong>
4.10
</strong>
</td>
<td style="text-align:center">
<strong>
4.11
</strong>
</td>
<td style="text-align:center">
<strong>
4.12
</strong>
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
<strong>
VMware TKGI version
</strong>
</td>
<td style="text-align:center">
<strong>
1.13
</strong>
</td>
<td style="text-align:center">
<strong>
1.14
</strong>
</td>
<td style="text-align:center">
<strong>
1.15
</strong>
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
<tr>
<td style="text-align:left">
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
deprecated
</td>
<td style="text-align:center">
supported
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
<td style="text-align:center">
</td>
</tr>
</tbody>
</table>
<p>
* Support added in this release
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Redis Enterprise for Kubernetes now uses RKE2 as the default for Rancher distributions.
</div>
</div>
<h3 id="images">
Images
</h3>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
redislabs/redis:6.4.2-94
</code>
</li>
<li>
<strong>
Operator
</strong>
:
<code>
redislabs/operator:6.4.2-8
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
redislabs/k8s-controller:6.4.2-8.
</code>
</li>
</ul>
<h4 id="openshift-images">
OpenShift images
</h4>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise:6.4.2-94.rhel8-openshift
</code>
(or
<code>
redislabs/redis-enterprise:6.4.2-94.rhel7-openshift
</code>
if upgrading from RHEL 7)
</li>
<li>
<strong>
Operator
</strong>
:
<code>
registry.connect.redhat.com/redislabs/redis-enterprise-operator:6.4.2-8
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
registry.connect.redhat.com/redislabs/services-manager:6.4.2-8
</code>
</li>
</ul>
<h4 id="olm-bundle">
OLM bundle
</h4>
<ul>
<li>
<strong>
Redis Enterprise operator bundle
</strong>
:
<code>
v6.4.2-8
</code>
</li>
</ul>
<h2 id="known-limitations">
Known limitations
</h2>
<ul>
<li>
<strong>
Air-gapped environments using Gears will get stuck during cluster recovery(RED-112076)
</strong>
This bug affects Redis Enterprise for Kubernetes versions older than 7.2.4-2.
</li>
</ul>
<h3 id="existing-limitations">
Existing limitations
</h3>
<ul>
<li>
<p>
<strong>
RERC resources must have a unique name (RED-96302)
</strong>
The string "rec-name"/"rec-namespace" must be different from all other participating clusters in teh Active-Active database.
</p>
</li>
<li>
<p>
<strong>
Admission is not blocking REAADB with
<code>
shardCount
</code>
which exceeds license quota (RED-96301)
</strong>
Fix the problems with the REAADB and reapply.
</p>
</li>
<li>
<p>
<strong>
Active-Active setup removal might keep services or routes undeleted (RED-77752)
</strong>
Delete services or routes manually if you encounter this problem.
</p>
</li>
<li>
<p>
<strong>
<code>
autoUpgrade
</code>
set to
<code>
true
</code>
can cause unexpected bdb upgrades when
<code>
redisUpgradePolicy
</code>
is set to
<code>
true
</code>
(RED-72351)
</strong>
Contact support if your deployment is impacted.
</p>
</li>
<li>
<p>
<strong>
Following the previous quick start guide version causes issues with creating an REDB due to unrecognized memory field name (RED-69515)
</strong>
The workaround is to use the newer (current) revision of Deploy Redis Enterprise Software for Kubernetes.
</p>
</li>
<li>
<p>
<strong>
PVC size issues when using decimal value in spec (RED-62132)
</strong>
Make sure you use integer values for the PVC size.
</p>
</li>
<li>
<p>
<strong>
REC might report error states on initial startup (RED-61707)
</strong>
There is no workaround at this time except to ignore the errors.
</p>
</li>
<li>
<p>
<strong>
Hashicorp Vault integration - no support for Gesher (RED-55080)
</strong>
There is no workaround for this issue. Gesher support has been deprecated.
</p>
</li>
<li>
<p>
<strong>
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</strong>
When REC clusters are deployed on Kubernetes clusters without synchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
</li>
<li>
<p>
<strong>
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</strong>
When an REC cluster is deployed in a project (namespace) and has REDB resources, the REDB resources must be deleted first before the REC can be deleted. Therefore, until the REDB resources are deleted, the project deletion will hang. The fix is to delete the REDB resources first and the REC second. Then, you can delete the project.
</p>
</li>
<li>
<p>
<strong>
Clusters must be named 'rec' in OLM-based deployments (RED-39825)
</strong>
In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (namely, "rec"). The workaround is to name the cluster "rec".
</p>
</li>
<li>
<p>
<strong>
Readiness probe incorrect on failures (RED-39300)
</strong>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
</li>
<li>
<p>
<strong>
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</strong>
DNS conflicts are possible between the cluster
<code>
mdns_server
</code>
and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names.
</p>
</li>
<li>
<p>
<strong>
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</strong>
In Kubernetes, the reported node CPU usage is the usage of the Kubernetes worker node hosting the REC pod.
</p>
</li>
<li>
<p>
<strong>
An unreachable cluster has status running (RED-32805)
</strong>
When a cluster is in unreachable state, the state remains
<code>
running
</code>
instead of triggering an error.
</p>
</li>
<li>
<p>
<strong>
Long cluster names cause routes to be rejected (RED-25871)
</strong>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name exceeds 63 characters. The workaround is to limit the cluster name to 20 characters or fewer.
</p>
</li>
<li>
<p>
<strong>
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</strong>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
</li>
</ul>
<h2 id="security">
Security
</h2>
<p>
For a list of fixes related to CVEs, see the
<a href="/docs/latest/operate/rs/release-notes/rs-6-4-2-releases/rs-6-4-2-94/">
Redis Enterprise 6.4.2-94 release notes
</a>
.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/6-4-2-releases/6-4-2-8/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/cloud-integrations/aws-marketplace/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Sign up for Redis Cloud with AWS Marketplace
</h1>
<p class="text-lg -mt-5 mb-10">
Shows how to subscribe to Redis Cloud using AWS Marketplace
</p>
<p>
You can use AWS Marketplace to subscribe to Redis Cloud through AWS Marketplace. This lets you provision according to your needs and pay using your AWS account.
</p>
<p>
Here's how to subscribe to Redis Cloud with AWS Marketplace:
</p>
<ol>
<li>
<p>
Sign in to the
<a href="https://console.aws.amazon.com/">
AWS console
</a>
.
</p>
</li>
<li>
<p>
Search AWS Marketplace for
<a href="https://aws.amazon.com/marketplace/pp/prodview-mwscixe4ujhkq">
Redis Cloud (Pay-As-You-Go with 14-day FREE TRIAL)
</a>
and subscribe to the listing.
</p>
<a href="/docs/latest/images/rc/aws-marketplace-rc-flexible-plan.png" sdata-lightbox="/images/rc/aws-marketplace-rc-flexible-plan.png">
<img alt="The Redis Cloud listing on AWS Marketplace" src="/docs/latest/images/rc/aws-marketplace-rc-flexible-plan.png"/>
</a>
<p>
Or, click on the URL provided by your Redis seller for a private offer for
<a href="https://aws.amazon.com/marketplace/pp/prodview-e6y7ork67pjwg?sr=0-3&ref_=beagle&applicationId=AWSMPContessa">
Redis Cloud - Annual Commits
</a>
and accept the private offer.
</p>
</li>
<li>
<p>
Locate the
<strong>
Set Up Your Account button
</strong>
, and then select it to begin mapping your Redis Cloud account with your AWS Marketplace account.
</p>
<a href="/docs/latest/images/rc/aws-marketplace-account-setup-button.png" sdata-lightbox="/images/rc/aws-marketplace-account-setup-button.png">
<img alt="Use the Set Up Your Account button after subscribing to Redis Cloud with your AWS Marketplace account." src="/docs/latest/images/rc/aws-marketplace-account-setup-button.png" width="50%"/>
</a>
</li>
<li>
<p>
Sign in to the
<a href="https://cloud.redis.io">
Redis Cloud console
</a>
. If you do not yet have an account, you will need to create one. You must have the
<strong>
Account Owner
</strong>
role.
</p>
</li>
<li>
<p>
Select the Redis account to be mapped to your AWS Marketplace account and confirm that your Marketplace account will pay for your Redis Cloud resources going forward.
</p>
<a href="/docs/latest/images/rc/aws-marketplace-map-account-dialog.png" sdata-lightbox="/images/rc/aws-marketplace-map-account-dialog.png">
<img alt="Use the AWS Marketplace dialog to map your Redis Cloud account to your AWS Marketplace account." src="/docs/latest/images/rc/aws-marketplace-map-account-dialog.png" width="80%"/>
</a>
</li>
<li>
<p>
Use the
<strong>
Connect account
</strong>
button to confirm your choice.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
You must complete this step to bill your Redis Cloud resources to your AWS Marketplace account.
</div>
</div>
</li>
<li>
<p>
Once your Redis account is mapped to your AWS Marketplace account, a message appears in the upper, left corner of the account panel.
</p>
<a href="/docs/latest/images/rc/aws-marketplace-billing-badge.png" sdata-lightbox="/images/rc/aws-marketplace-billing-badge.png">
<img alt="The AWS Marketplace badge appears when your Redis Cloud account is mapped to an AWS Marketplace account." src="/docs/latest/images/rc/aws-marketplace-billing-badge.png" width="150px"/>
</a>
<p>
In addition, AWS Marketplace is reported as the selected payment method.
</p>
</li>
</ol>
<p>
At this point, you can create a new database using the
<a href="/docs/latest/operate/rc/databases/create-database/">
standard workflow
</a>
, with one important change. You don't need to enter a payment method, as it's automatically assigned to your AWS Marketplace account.
</p>
<p>
To confirm this, review the payment method associated with your subscription.
</p>
<p>
If your AWS Marketplace account is deactivated or otherwise unavailable, you won't be able to use your databases until the billing method is updated. For help,
<a href="https://redis.io/support/">
contact support
</a>
.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/cloud-integrations/aws-marketplace/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/user/.html | <section class="prose w-full py-12 max-w-none">
<h1>
User object
</h1>
<p class="text-lg -mt-5 mb-10">
An object that represents a Redis Enterprise user
</p>
<p>
An API object that represents a Redis Enterprise user.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
uid
</td>
<td>
integer
</td>
<td>
User's unique ID
</td>
</tr>
<tr>
<td>
account_id
</td>
<td>
integer
</td>
<td>
SM account ID
</td>
</tr>
<tr>
<td>
action_uid
</td>
<td>
string
</td>
<td>
Action UID. If it exists, progress can be tracked by the
<code>
GET
</code>
<code>
/actions/{uid}
</code>
API request (read-only)
</td>
</tr>
<tr>
<td>
auth_method
</td>
<td>
<strong>
'regular'
</strong>
</td>
<td>
User's authentication method (deprecated as of Redis Enterprise v7.2)
</td>
</tr>
<tr>
<td>
bdbs_email_alerts
</td>
<td>
complex object
</td>
<td>
UIDs of databases that user will receive alerts for
</td>
</tr>
<tr>
<td>
cluster_email_alerts
</td>
<td>
boolean
</td>
<td>
Activate cluster email alerts for a user
</td>
</tr>
<tr>
<td>
email
</td>
<td>
string
</td>
<td>
User's email (pattern matching only ASCII characters)
</td>
</tr>
<tr>
<td>
email_alerts
</td>
<td>
boolean (default:Β true)
</td>
<td>
Activate email alerts for a user
</td>
</tr>
<tr>
<td>
name
</td>
<td>
string
</td>
<td>
User's name (pattern does not allow non-ASCII and special characters &,<,>,")
</td>
</tr>
<tr>
<td>
password
</td>
<td>
string
</td>
<td>
User's password. If
<code>
password_hash_method
</code>
is set to
<code>
1
</code>
, the password should be hashed using SHA-256. The format before hashing is
<code>
username:clustername:password
</code>
.
</td>
</tr>
<tr>
<td>
password_hash_method
</td>
<td>
'1'
</td>
<td>
Used when password is passed pre-hashed to specify the hashing method
</td>
</tr>
<tr>
<td>
password_issue_date
</td>
<td>
string
</td>
<td>
The date in which the password was set (read-only)
</td>
</tr>
<tr>
<td>
role
</td>
<td>
'admin'
<br/>
'cluster_member'
<br/>
'cluster_viewer'
<br/>
'db_member'
<br/>
<strong>
'db_viewer'
</strong>
<br/>
'none'
</td>
<td>
User's
<a href="/docs/latest/operate/rs/7.4/references/rest-api/permissions/#roles">
role
</a>
</td>
</tr>
<tr>
<td>
role_uids
</td>
<td>
array of integers
</td>
<td>
UIDs of user's roles for role-based access control
</td>
</tr>
<tr>
<td>
status
</td>
<td>
'active'
<br/>
'locked'
</td>
<td>
User sign-in status (read-only)
<br/>
<strong>
active
</strong>
: able to sign in
<br/>
<strong>
locked
</strong>
: unable to sign in
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/user/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/geosearch/.html | <section class="prose w-full py-12">
<h1 class="command-name">
GEOSEARCH
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">GEOSEARCH key <FROMMEMBERΒ member | FROMLONLATΒ longitude latitude>
<BYRADIUSΒ radius <m | km | ft | mi> | BYBOXΒ width height <m | km |
ft | mi>> [ASC | DESC] [COUNTΒ count [ANY]] [WITHCOORD] [WITHDIST]
[WITHHASH]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
6.2.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N+log(M)) where N is the number of elements in the grid-aligned bounding box area around the shape provided as the filter and M is the number of items inside the shape
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@read
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@geo
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Return the members of a sorted set populated with geospatial information using
<a href="/docs/latest/commands/geoadd/">
<code>
GEOADD
</code>
</a>
, which are within the borders of the area specified by a given shape. This command extends the
<a href="/docs/latest/commands/georadius/">
<code>
GEORADIUS
</code>
</a>
command, so in addition to searching within circular areas, it supports searching within rectangular areas.
</p>
<p>
This command should be used in place of the deprecated
<a href="/docs/latest/commands/georadius/">
<code>
GEORADIUS
</code>
</a>
and
<a href="/docs/latest/commands/georadiusbymember/">
<code>
GEORADIUSBYMEMBER
</code>
</a>
commands.
</p>
<p>
The query's center point is provided by one of these mandatory options:
</p>
<ul>
<li>
<code>
FROMMEMBER
</code>
: Use the position of the given existing
<code>
<member>
</code>
in the sorted set.
</li>
<li>
<code>
FROMLONLAT
</code>
: Use the given
<code>
<longitude>
</code>
and
<code>
<latitude>
</code>
position.
</li>
</ul>
<p>
The query's shape is provided by one of these mandatory options:
</p>
<ul>
<li>
<code>
BYRADIUS
</code>
: Similar to
<a href="/docs/latest/commands/georadius/">
<code>
GEORADIUS
</code>
</a>
, search inside circular area according to given
<code>
<radius>
</code>
.
</li>
<li>
<code>
BYBOX
</code>
: Search inside an axis-aligned rectangle, determined by
<code>
<height>
</code>
and
<code>
<width>
</code>
.
</li>
</ul>
<p>
The command optionally returns additional information using the following options:
</p>
<ul>
<li>
<code>
WITHDIST
</code>
: Also return the distance of the returned items from the specified center point. The distance is returned in the same unit as specified for the radius or height and width arguments.
</li>
<li>
<code>
WITHCOORD
</code>
: Also return the longitude and latitude of the matching items.
</li>
<li>
<code>
WITHHASH
</code>
: Also return the raw geohash-encoded sorted set score of the item, in the form of a 52 bit unsigned integer. This is only useful for low level hacks or debugging and is otherwise of little interest for the general user.
</li>
</ul>
<p>
Matching items are returned unsorted by default. To sort them, use one of the following two options:
</p>
<ul>
<li>
<code>
ASC
</code>
: Sort returned items from the nearest to the farthest, relative to the center point.
</li>
<li>
<code>
DESC
</code>
: Sort returned items from the farthest to the nearest, relative to the center point.
</li>
</ul>
<p>
All matching items are returned by default. To limit the results to the first N matching items, use the
<strong>
COUNT
<code>
<count>
</code>
</strong>
option.
When the
<code>
ANY
</code>
option is used, the command returns as soon as enough matches are found. This means that the results returned may not be the ones closest to the specified point, but the effort invested by the server to generate them is significantly less.
When
<code>
ANY
</code>
is not provided, the command will perform an effort that is proportional to the number of items matching the specified area and sort them,
so to query very large areas with a very small
<code>
COUNT
</code>
option may be slow even if just a few results are returned.
</p>
<h2 id="examples">
Examples
</h2>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"
(integer) 2
redis> GEOADD Sicily 12.758489 38.788135 "edge1" 17.241510 38.788135 "edge2"
(integer) 2
redis> GEOSEARCH Sicily FROMLONLAT 15 37 BYRADIUS 200 km ASC
1) "Catania"
2) "Palermo"
redis> GEOSEARCH Sicily FROMLONLAT 15 37 BYBOX 400 400 km ASC WITHCOORD WITHDIST
1) 1) "Catania"
2) "56.4413"
3) 1) "15.08726745843887329"
2) "37.50266842333162032"
2) 1) "Palermo"
2) "190.4424"
3) 1) "13.36138933897018433"
2) "38.11555639549629859"
3) 1) "edge2"
2) "279.7403"
3) 1) "17.24151045083999634"
2) "38.78813451624225195"
4) 1) "edge1"
2) "279.7405"
3) 1) "12.7584877610206604"
2) "38.78813451624225195"
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
If no
<code>
WITH*
</code>
option is specified, an
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
of matched member names
</li>
<li>
If
<code>
WITHCOORD
</code>
,
<code>
WITHDIST
</code>
, or
<code>
WITHHASH
</code>
options are specified, the command returns an
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
of arrays, where each sub-array represents a single item:
<ul>
<li>
The distance from the center as a floating point number, in the same unit specified in the radius.
</li>
<li>
The Geohash integer.
</li>
<li>
The coordinates as a two items x,y array (longitude,latitude).
</li>
</ul>
</li>
</ul>
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Added support for uppercase unit names.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/geosearch/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/changelog/2023/october-2023/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud changelog (October 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
New features, enhancements, and other changes added to Redis Cloud during October 2023.
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="cost-report-csv-download">
Cost report CSV download
</h3>
<p>
You can now download shard cost reports in CSV format from the
<a href="/docs/latest/operate/rc/billing-and-payments/">
<strong>
Billing and Payments
</strong>
</a>
and
<a href="/docs/latest/operate/rc/logs-reports/usage-reports/">
<strong>
Usage Reports
</strong>
</a>
pages.
</p>
<p>
Select the
<strong>
Cost report
</strong>
button to download a report of all shard costs in CSV format.
</p>
<a href="/docs/latest/images/rc/button-cost-report-download.png" sdata-lightbox="/images/rc/button-cost-report-download.png">
<img alt="The cost report download button." src="/docs/latest/images/rc/button-cost-report-download.png" width="150px"/>
</a>
<p>
The report gives a breakdown of all your Redis billing unit costs, per subscription and database, by month. Subscriptions under the minimum subscription price are broken down into actual billing unit prices and the difference from minimum price.
</p>
<h3 id="saml-account-linking-tokens">
SAML account linking tokens
</h3>
<p>
The process for
<a href="/docs/latest/operate/rc/security/access-control/saml-sso/#link-other-accounts">
linking new Redis accounts
</a>
to your
<a href="/docs/latest/operate/rc/security/access-control/saml-sso/">
SAML single sign-on
</a>
configuration has changed to enhance security. Now, both accounts must use a token to ensure that the connection is legitimate.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/changelog/2023/october-2023/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/databases/durability-ha/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Durability and high availability
</h1>
<p class="text-lg -mt-5 mb-10">
Overview of Redis Enterprise durability features such as replication, clustering, and rack-zone awareness.
</p>
<p>
Redis Enterprise Software comes with several features that make your data more durable and accessible. The following features can help protect your data in cases of failures or outages and help keep your data available when you need it.
</p>
<h2 id="replication">
Replication
</h2>
<p>
When you
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/replication/">
replicate your database
</a>
, each database instance (shard) is copied one or more times. Your database will have one primary shard and one or more replica shards. When a primary shard fails, Redis Enterprise automatically promotes a replica shard to primary.
</p>
<h2 id="clustering">
Clustering
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/clustering/">
Clustering
</a>
(or sharding) breaks your database into individual instances (shards) and spreads them across several nodes. Clustering lets you add resources to your cluster to scale your database and prevents node failures from causing availability loss.
</p>
<h2 id="database-persistence">
Database persistence
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/configure/database-persistence/">
Database persistence
</a>
gives your database durability against process or server failures by saving data to disk at set intervals.
</p>
<h2 id="active-active-geo-distributed-replication">
Active-Active geo-distributed replication
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active Redis Enterprise databases
</a>
distribute your replicated data across multiple nodes and availability zones. This increases the durability of your database by reducing the likelihood of data or availability loss. It also reduces data access latency.
</p>
<h2 id="rack-zone-awareness">
Rack-zone awareness
</h2>
<p>
<a href="/docs/latest/operate/rs/7.4/clusters/configure/rack-zone-awareness/">
Rack-zone awareness
</a>
maps each node in your Redis Enterprise cluster to a physical rack or logical zone. The cluster uses this information to distribute primary shards and their replica shards in different racks or zones. This ensures data availability if a rack or zone fails.
</p>
<h2 id="discovery-service">
Discovery service
</h2>
<p>
The
<a href="/docs/latest/operate/rs/7.4/databases/durability-ha/discovery-service/">
discovery service
</a>
provides an IP-based connection management service used when connecting to Redis Enterprise Software databases. It lets your application discover which node hosts the database endpoint. The discovery service API complies with the
<a href="/docs/latest/operate/oss_and_stack/management/sentinel/#sentinel-api">
Redis Sentinel API
</a>
.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/durability-ha/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/ts.mrange.html | <section class="prose w-full py-12">
<h1 class="command-name">
TS.MRANGE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TS.MRANGE fromTimestamp toTimestamp
[LATEST]
[FILTER_BY_TS ts...]
[FILTER_BY_VALUE min max]
[WITHLABELS | <SELECTED_LABELS label...>]
[COUNT count]
[[ALIGN align] AGGREGATION aggregator bucketDuration [BUCKETTIMESTAMP bt] [EMPTY]]
FILTER filterExpr...
[GROUPBY label REDUCE reducer]
</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/timeseries">
TimeSeries 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(n/m+k) where n = Number of data points, m = Chunk size (data points per chunk), k = Number of data points that are in the requested ranges
</dd>
</dl>
<p>
Query a range across multiple time series by filters in the forward direction
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
fromTimestamp
</code>
</summary>
<p>
is the start timestamp for the range query (integer Unix timestamp in milliseconds) or
<code>
-
</code>
to denote the timestamp of the earliest sample among all the time series that passes
<code>
FILTER filterExpr...
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
toTimestamp
</code>
</summary>
<p>
is the end timestamp for the range query (integer Unix timestamp in milliseconds) or
<code>
+
</code>
to denote the timestamp of the latest sample among all the time series that passes
<code>
FILTER filterExpr...
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
FILTER filterExpr...
</code>
</summary>
<p>
filters time series based on their labels and label values. Each filter expression has one of the following syntaxes:
</p>
<ul>
<li>
<code>
label!=
</code>
- the time series has a label named
<code>
label
</code>
</li>
<li>
<code>
label=value
</code>
- the time series has a label named
<code>
label
</code>
with a value equal to
<code>
value
</code>
</li>
<li>
<code>
label=(value1,value2,...)
</code>
- the time series has a label named
<code>
label
</code>
with a value equal to one of the values in the list
</li>
<li>
<code>
label=
</code>
- the time series does not have a label named
<code>
label
</code>
</li>
<li>
<code>
label!=value
</code>
- the time series does not have a label named
<code>
label
</code>
with a value equal to
<code>
value
</code>
</li>
<li>
<code>
label!=(value1,value2,...)
</code>
- the time series does not have a label named
<code>
label
</code>
with a value equal to any of the values in the list
</li>
</ul>
<p>
<note>
<b>
Notes:
</b>
</note>
</p>
<ul>
<li>
At least one filter expression with a syntax
<code>
label=value
</code>
or
<code>
label=(value1,value2,...)
</code>
is required.
</li>
<li>
Filter expressions are conjunctive. For example, the filter
<code>
type=temperature room=study
</code>
means that a time series is a temperature time series of a study room.
</li>
<li>
Whitespaces are unallowed in a filter expression except between quotes or double quotes in values - e.g.,
<code>
x="y y"
</code>
or
<code>
x='(y y,z z)'
</code>
.
</li>
</ul>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
LATEST
</code>
(since RedisTimeSeries v1.8)
</summary>
<p>
is used when a time series is a compaction. With
<code>
LATEST
</code>
, TS.MRANGE also reports the compacted value of the latest (possibly partial) bucket, given that this bucket's start time falls within
<code>
[fromTimestamp, toTimestamp]
</code>
. Without
<code>
LATEST
</code>
, TS.MRANGE does not report the latest (possibly partial) bucket. When a time series is not a compaction,
<code>
LATEST
</code>
is ignored.
</p>
<p>
The data in the latest bucket of a compaction is possibly partial. A bucket is
<em>
closed
</em>
and compacted only upon the arrival of a new sample that
<em>
opens
</em>
a new
<em>
latest
</em>
bucket. There are cases, however, when the compacted value of the latest (possibly partial) bucket is also required. In such a case, use
<code>
LATEST
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
FILTER_BY_TS ts...
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
filters samples by a list of specific timestamps. A sample passes the filter if its exact timestamp is specified and falls within
<code>
[fromTimestamp, toTimestamp]
</code>
.
</p>
<p>
When used together with
<code>
AGGREGATION
</code>
: samples are filtered before being aggregated.
</p>
</details>
<details open="">
<summary>
<code>
FILTER_BY_VALUE min max
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
filters samples by minimum and maximum values.
</p>
<p>
When used together with
<code>
AGGREGATION
</code>
: samples are filtered before being aggregated.
</p>
</details>
<details open="">
<summary>
<code>
WITHLABELS
</code>
</summary>
<p>
includes in the reply all label-value pairs representing metadata labels of the time series.
If
<code>
WITHLABELS
</code>
or
<code>
SELECTED_LABELS
</code>
are not specified, by default, an empty list is reported as label-value pairs.
</p>
</details>
<details open="">
<summary>
<code>
SELECTED_LABELS label...
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
returns a subset of the label-value pairs that represent metadata labels of the time series.
Use when a large number of labels exists per series, but only the values of some of the labels are required.
If
<code>
WITHLABELS
</code>
or
<code>
SELECTED_LABELS
</code>
are not specified, by default, an empty list is reported as label-value pairs.
</p>
</details>
<details open="">
<summary>
<code>
COUNT count
</code>
</summary>
<p>
When used without
<code>
AGGREGATION
</code>
: limits the number of reported samples per time series.
</p>
<p>
When used together with
<code>
AGGREGATION
</code>
: limits the number of reported buckets.
</p>
</details>
<details open="">
<summary>
<code>
ALIGN align
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
is a time bucket alignment control for
<code>
AGGREGATION
</code>
. It controls the time bucket timestamps by changing the reference timestamp on which a bucket is defined.
</p>
<p>
Values include:
</p>
<ul>
<li>
<code>
start
</code>
or
<code>
-
</code>
: The reference timestamp will be the query start interval time (
<code>
fromTimestamp
</code>
) which can't be
<code>
-
</code>
</li>
<li>
<code>
end
</code>
or
<code>
+
</code>
: The reference timestamp will be the query end interval time (
<code>
toTimestamp
</code>
) which can't be
<code>
+
</code>
</li>
<li>
A specific timestamp: align the reference timestamp to a specific time
</li>
</ul>
<p>
<note>
<b>
Note:
</b>
When not provided, alignment is set to
<code>
0
</code>
.
</note>
</p>
</details>
<details open="">
<summary>
<code>
AGGREGATION aggregator bucketDuration
</code>
</summary>
<p>
per time series, aggregates samples into time buckets, where:
</p>
<ul>
<li>
<p>
<code>
aggregator
</code>
takes one of the following aggregation types:
</p>
<table>
<thead>
<tr>
<th>
<code>
aggregator
</code>
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
avg
</code>
</td>
<td>
Arithmetic mean of all values
</td>
</tr>
<tr>
<td>
<code>
sum
</code>
</td>
<td>
Sum of all values
</td>
</tr>
<tr>
<td>
<code>
min
</code>
</td>
<td>
Minimum value
</td>
</tr>
<tr>
<td>
<code>
max
</code>
</td>
<td>
Maximum value
</td>
</tr>
<tr>
<td>
<code>
range
</code>
</td>
<td>
Difference between maximum value and minimum value
</td>
</tr>
<tr>
<td>
<code>
count
</code>
</td>
<td>
Number of values
</td>
</tr>
<tr>
<td>
<code>
first
</code>
</td>
<td>
Value with lowest timestamp in the bucket
</td>
</tr>
<tr>
<td>
<code>
last
</code>
</td>
<td>
Value with highest timestamp in the bucket
</td>
</tr>
<tr>
<td>
<code>
std.p
</code>
</td>
<td>
Population standard deviation of the values
</td>
</tr>
<tr>
<td>
<code>
std.s
</code>
</td>
<td>
Sample standard deviation of the values
</td>
</tr>
<tr>
<td>
<code>
var.p
</code>
</td>
<td>
Population variance of the values
</td>
</tr>
<tr>
<td>
<code>
var.s
</code>
</td>
<td>
Sample variance of the values
</td>
</tr>
<tr>
<td>
<code>
twa
</code>
</td>
<td>
Time-weighted average over the bucket's timeframe (since RedisTimeSeries v1.8)
</td>
</tr>
</tbody>
</table>
</li>
<li>
<p>
<code>
bucketDuration
</code>
is duration of each bucket, in milliseconds.
</p>
</li>
</ul>
<p>
Without
<code>
ALIGN
</code>
, bucket start times are multiples of
<code>
bucketDuration
</code>
.
</p>
<p>
With
<code>
ALIGN align
</code>
, bucket start times are multiples of
<code>
bucketDuration
</code>
with remainder
<code>
align % bucketDuration
</code>
.
</p>
<p>
The first bucket start time is less than or equal to
<code>
fromTimestamp
</code>
.
</p>
</details>
<details open="">
<summary>
<code>
[BUCKETTIMESTAMP bt]
</code>
(since RedisTimeSeries v1.8)
</summary>
<p>
controls how bucket timestamps are reported.
</p>
<table>
<thead>
<tr>
<th>
<code>
bt
</code>
</th>
<th>
Timestamp reported for each bucket
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
-
</code>
or
<code>
start
</code>
</td>
<td>
the bucket's start time (default)
</td>
</tr>
<tr>
<td>
<code>
+
</code>
or
<code>
end
</code>
</td>
<td>
the bucket's end time
</td>
</tr>
<tr>
<td>
<code>
~
</code>
or
<code>
mid
</code>
</td>
<td>
the bucket's mid time (rounded down if not an integer)
</td>
</tr>
</tbody>
</table>
</details>
<details open="">
<summary>
<code>
[EMPTY]
</code>
(since RedisTimeSeries v1.8)
</summary>
<p>
is a flag, which, when specified, reports aggregations also for empty buckets.
</p>
<table>
<thead>
<tr>
<th>
<code>
aggregator
</code>
</th>
<th>
Value reported for each empty bucket
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
sum
</code>
,
<code>
count
</code>
</td>
<td>
<code>
0
</code>
</td>
</tr>
<tr>
<td>
<code>
last
</code>
</td>
<td>
The value of the last sample before the bucket's start.
<code>
NaN
</code>
when no such sample.
</td>
</tr>
<tr>
<td>
<code>
twa
</code>
</td>
<td>
Average value over the bucket's timeframe based on linear interpolation of the last sample before the bucket's start and the first sample after the bucket's end.
<code>
NaN
</code>
when no such samples.
</td>
</tr>
<tr>
<td>
<code>
min
</code>
,
<code>
max
</code>
,
<code>
range
</code>
,
<code>
avg
</code>
,
<code>
first
</code>
,
<code>
std.p
</code>
,
<code>
std.s
</code>
</td>
<td>
<code>
NaN
</code>
</td>
</tr>
</tbody>
</table>
<p>
Regardless of the values of
<code>
fromTimestamp
</code>
and
<code>
toTimestamp
</code>
, no data is reported for buckets that end before the earliest sample or begin after the latest sample in the time series.
</p>
</details>
<details open="">
<summary>
<code>
GROUPBY label REDUCE reducer
</code>
(since RedisTimeSeries v1.6)
</summary>
<p>
splits time series into groups, each group contains time series that share the same value for the provided label name, then aggregates results in each group.
</p>
<p>
When combined with
<code>
AGGREGATION
</code>
the
<code>
GROUPBY
</code>
/
<code>
REDUCE
</code>
is applied post aggregation stage.
</p>
<ul>
<li>
<p>
<code>
label
</code>
is label name. A group is created for all time series that share the same value for this label.
</p>
</li>
<li>
<p>
<code>
reducer
</code>
is an aggregation type used to aggregate the results in each group.
</p>
<table>
<thead>
<tr>
<th>
<code>
reducer
</code>
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
avg
</code>
</td>
<td>
Arithmetic mean of all non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
sum
</code>
</td>
<td>
Sum of all non-NaN values
</td>
</tr>
<tr>
<td>
<code>
min
</code>
</td>
<td>
Minimum non-NaN value
</td>
</tr>
<tr>
<td>
<code>
max
</code>
</td>
<td>
Maximum non-NaN value
</td>
</tr>
<tr>
<td>
<code>
range
</code>
</td>
<td>
Difference between maximum non-NaN value and minimum non-NaN value (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
count
</code>
</td>
<td>
Number of non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
std.p
</code>
</td>
<td>
Population standard deviation of all non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
std.s
</code>
</td>
<td>
Sample standard deviation of all non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
var.p
</code>
</td>
<td>
Population variance of all non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
<tr>
<td>
<code>
var.s
</code>
</td>
<td>
Sample variance of all non-NaN values (since RedisTimeSeries v1.8)
</td>
</tr>
</tbody>
</table>
</li>
</ul>
<p>
<note>
<b>
Notes:
</b>
</note>
</p>
<ul>
<li>
The produced time series is named
<code>
<label>=<value>
</code>
</li>
<li>
The produced time series contains two labels with these label array structures:
<ul>
<li>
<code>
__reducer__
</code>
, the reducer used (e.g.,
<code>
"count"
</code>
)
</li>
<li>
<code>
__source__
</code>
, the list of time series keys used to compute the grouped series (e.g.,
<code>
"key1,key2,key3"
</code>
)
</li>
</ul>
</li>
</ul>
</details>
<p>
<note>
<b>
Note:
</b>
An
<code>
MRANGE
</code>
command cannot be part of a transaction when running on a Redis cluster.
</note>
</p>
<h2 id="return-value">
Return value
</h2>
<p>
If
<code>
GROUPBY label REDUCE reducer
</code>
is not specified:
</p>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: for each time series matching the specified filters, the following is reported:
<ul>
<li>
bulk-string-reply: The time series key name
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: label-value pairs (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
)
<ul>
<li>
By default, an empty array is reported
</li>
<li>
If
<code>
WITHLABELS
</code>
is specified, all labels associated with this time series are reported
</li>
<li>
If
<code>
SELECTED_LABELS label...
</code>
is specified, the selected labels are reported (null value when no such label defined)
</li>
</ul>
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: timestamp-value pairs (
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
(double)): all samples/aggregations matching the range
</li>
</ul>
</li>
</ul>
<p>
If
<code>
GROUPBY label REDUCE reducer
</code>
is specified:
</p>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: for each group of time series matching the specified filters, the following is reported:
<ul>
<li>
bulk-string-reply with the format
<code>
label=value
</code>
where
<code>
label
</code>
is the
<code>
GROUPBY
</code>
label argument
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: label-value pairs (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
):
<ul>
<li>
By default, an empty array is reported
</li>
<li>
If
<code>
WITHLABELS
</code>
is specified, the
<code>
GROUPBY
</code>
label argument and value are reported
</li>
<li>
If
<code>
SELECTED_LABELS label...
</code>
is specified, the selected labels are reported (null value when no such label defined or label does not have the same value for all grouped time series)
</li>
</ul>
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: either a single pair (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
): the
<code>
GROUPBY
</code>
label argument and value, or empty array if
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: a single pair (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
): the string
<code>
__reducer__
</code>
and the reducer argument
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: a single pair (
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-strings">
Bulk string reply
</a>
): the string
<code>
__source__
</code>
and the time series key names separated by
<code>
,
</code>
</li>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
: timestamp-value pairs (
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
,
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
(double)): all samples/aggregations matching the range
</li>
</ul>
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Retrieve maximum stock price per timestamp
</b>
</summary>
<p>
Create two stocks and add their prices at three different timestamps.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE stock:A LABELS <span class="nb">type</span> stock name A
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE stock:B LABELS <span class="nb">type</span> stock name B
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:A <span class="m">1000</span> <span class="m">100</span> stock:A <span class="m">1010</span> <span class="m">110</span> stock:A <span class="m">1020</span> <span class="m">120</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:B <span class="m">1000</span> <span class="m">120</span> stock:B <span class="m">1010</span> <span class="m">110</span> stock:B <span class="m">1020</span> <span class="m">100</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span></span></span></code></pre>
</div>
<p>
You can now retrieve the maximum stock price per timestamp.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.MRANGE - + WITHLABELS FILTER <span class="nv">type</span><span class="o">=</span>stock GROUPBY <span class="nb">type</span> REDUCE max
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type=stock"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"stock"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__reducer__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"max"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__source__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"stock:A,stock:B"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">120</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">110</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">120</span></span></span></code></pre>
</div>
<p>
The
<code>
FILTER type=stock
</code>
clause returns a single time series representing stock prices. The
<code>
GROUPBY type REDUCE max
</code>
clause splits the time series into groups with identical type values, and then, for each timestamp, aggregates all series that share the same type value using the max aggregator.
</p>
</details>
<details open="">
<summary>
<b>
Calculate average stock price and retrieve maximum average
</b>
</summary>
<p>
Create two stocks and add their prices at nine different timestamps.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE stock:A LABELS <span class="nb">type</span> stock name A
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.CREATE stock:B LABELS <span class="nb">type</span> stock name B
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:A <span class="m">1000</span> <span class="m">100</span> stock:A <span class="m">1010</span> <span class="m">110</span> stock:A <span class="m">1020</span> <span class="m">120</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:B <span class="m">1000</span> <span class="m">120</span> stock:B <span class="m">1010</span> <span class="m">110</span> stock:B <span class="m">1020</span> <span class="m">100</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:A <span class="m">2000</span> <span class="m">200</span> stock:A <span class="m">2010</span> <span class="m">210</span> stock:A <span class="m">2020</span> <span class="m">220</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:B <span class="m">2000</span> <span class="m">220</span> stock:B <span class="m">2010</span> <span class="m">210</span> stock:B <span class="m">2020</span> <span class="m">200</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:A <span class="m">3000</span> <span class="m">300</span> stock:A <span class="m">3010</span> <span class="m">310</span> stock:A <span class="m">3020</span> <span class="m">320</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3020</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MADD stock:B <span class="m">3000</span> <span class="m">320</span> stock:B <span class="m">3010</span> <span class="m">310</span> stock:B <span class="m">3020</span> <span class="m">300</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3000</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3010</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3020</span></span></span></code></pre>
</div>
<p>
Now, for each stock, calculate the average stock price per a 1000-millisecond timeframe, and then retrieve the stock with the maximum average for that timeframe.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.MRANGE - + WITHLABELS AGGREGATION avg <span class="m">1000</span> FILTER <span class="nv">type</span><span class="o">=</span>stock GROUPBY <span class="nb">type</span> REDUCE max
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type=stock"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"type"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"stock"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__reducer__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"max"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__source__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"stock:A,stock:B"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">110</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">2000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">210</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">310</span></span></span></code></pre>
</div>
</details>
<details open="">
<summary>
<b>
Group query results
</b>
</summary>
<p>
Query all time series with the metric label equal to
<code>
cpu
</code>
, then group the time series by the value of their
<code>
metric_name
</code>
label value and for each group return the maximum value and the time series keys (
<em>
source
</em>
) with that value.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149180000</span> <span class="m">90</span> labels metric cpu metric_name system
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149185000</span> <span class="m">45</span>
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149185000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts2 <span class="m">1548149180000</span> <span class="m">99</span> labels metric cpu metric_name user
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MRANGE - + WITHLABELS FILTER <span class="nv">metric</span><span class="o">=</span>cpu GROUPBY metric_name REDUCE max
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name=system"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"system"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__reducer__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"max"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__source__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"ts1"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">90</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149185000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">45</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name=user"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"user"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__reducer__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"max"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"__source__"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"ts2"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">99</span></span></span></code></pre>
</div>
</details>
<details open="">
<summary>
<b>
Filter query by value
</b>
</summary>
<p>
Query all time series with the metric label equal to
<code>
cpu
</code>
, then filter values larger or equal to 90.0 and smaller or equal to 100.0.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149180000</span> <span class="m">90</span> labels metric cpu metric_name system
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149185000</span> <span class="m">45</span>
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149185000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts2 <span class="m">1548149180000</span> <span class="m">99</span> labels metric cpu metric_name user
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MRANGE - + FILTER_BY_VALUE <span class="m">90</span> <span class="m">100</span> WITHLABELS FILTER <span class="nv">metric</span><span class="o">=</span>cpu
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"ts1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"cpu"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"system"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">90</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"ts2"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"cpu"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"metric_name"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"user"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">99</span></span></span></code></pre>
</div>
</details>
<details open="">
<summary>
<b>
Query using a label
</b>
</summary>
<p>
Query all time series with the metric label equal to
<code>
cpu
</code>
, but only return the team label.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149180000</span> <span class="m">90</span> labels metric cpu metric_name system team NY
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts1 <span class="m">1548149185000</span> <span class="m">45</span>
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149185000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.ADD ts2 <span class="m">1548149180000</span> <span class="m">99</span> labels metric cpu metric_name user team SF
</span></span><span class="line"><span class="cl"><span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl">127.0.0.1:6379> TS.MRANGE - + SELECTED_LABELS team FILTER <span class="nv">metric</span><span class="o">=</span>cpu
</span></span><span class="line"><span class="cl">1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"ts1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"team"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"NY"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">90</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149185000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">45</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"ts2"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="s2">"team"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"SF"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> 1<span class="o">)</span> 1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">1548149180000</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="m">99</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/ts.range/">
<code>
TS.RANGE
</code>
</a>
|
<a href="/docs/latest/commands/ts.mrevrange/">
<code>
TS.MREVRANGE
</code>
</a>
|
<a href="/docs/latest/commands/ts.revrange/">
<code>
TS.REVRANGE
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<p>
<a href="/docs/latest/develop/data-types/timeseries/">
RedisTimeSeries
</a>
</p>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/ts.mrange/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-mac-os/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Install Redis on macOS
</h1>
<p class="text-lg -mt-5 mb-10">
Use Homebrew to install and start Redis on macOS
</p>
<p>
This guide shows you how to install Redis on macOS using Homebrew. Homebrew is the easiest way to install Redis on macOS. If you'd prefer to build Redis from the source files on macOS, see
<a href="/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-from-source/">
Installing Redis from Source
</a>
.
</p>
<h2 id="prerequisites">
Prerequisites
</h2>
<p>
First, make sure you have Homebrew installed. From the terminal, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">brew --version</span></span></code></pre>
</div>
<p>
If this command fails, you'll need to
<a href="https://brew.sh/">
follow the Homebrew installation instructions
</a>
.
</p>
<h2 id="installation">
Installation
</h2>
<p>
From the terminal, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">brew install redis</span></span></code></pre>
</div>
<p>
This will install Redis on your system.
</p>
<h2 id="starting-and-stopping-redis-in-the-foreground">
Starting and stopping Redis in the foreground
</h2>
<p>
To test your Redis installation, you can run the
<code>
redis-server
</code>
executable from the command line:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis-server</span></span></code></pre>
</div>
<p>
If successful, you'll see the startup logs for Redis, and Redis will be running in the foreground.
</p>
<p>
To stop Redis, enter
<code>
Ctrl-C
</code>
.
</p>
<h3 id="starting-and-stopping-redis-using-launchd">
Starting and stopping Redis using launchd
</h3>
<p>
As an alternative to running Redis in the foreground, you can also use
<code>
launchd
</code>
to start the process in the background:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">brew services start redis</span></span></code></pre>
</div>
<p>
This launches Redis and restarts it at login. You can check the status of a
<code>
launchd
</code>
managed Redis by running the following:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">brew services info redis</span></span></code></pre>
</div>
<p>
If the service is running, you'll see output like the following:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis <span class="o">(</span>homebrew.mxcl.redis<span class="o">)</span>
</span></span><span class="line"><span class="cl">Running: β
</span></span><span class="line"><span class="cl">Loaded: β
</span></span><span class="line"><span class="cl">User: miranda
</span></span><span class="line"><span class="cl">PID: <span class="m">67975</span></span></span></code></pre>
</div>
<p>
To stop the service, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">brew services stop redis</span></span></code></pre>
</div>
<h2 id="connect-to-redis">
Connect to Redis
</h2>
<p>
Once Redis is running, you can test it by running
<code>
redis-cli
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis-cli</span></span></code></pre>
</div>
<p>
Test the connection with the
<code>
ping
</code>
command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> ping
</span></span><span class="line"><span class="cl">PONG</span></span></code></pre>
</div>
<p>
You can also test that your Redis server is running using
<a href="/docs/latest/develop/tools/insight/">
Redis Insight
</a>
.
</p>
<h2 id="next-steps">
Next steps
</h2>
<p>
Once you have a running Redis instance, you may want to:
</p>
<ul>
<li>
Try the
<a href="/docs/latest/develop/tools/cli/">
Redis CLI tutorial
</a>
</li>
<li>
Connect using one of the
<a href="/docs/latest/develop/clients/">
Redis clients
</a>
</li>
<li>
<a href="/docs/latest/operate/oss_and_stack/install/install-redis/#install-redis-properly">
Install Redis "properly"
</a>
for production use.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-mac-os/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/data-types/strings/.html | <section class="prose w-full py-12">
<h1>
Redis Strings
</h1>
<p class="text-lg -mt-5 mb-10">
Introduction to Redis strings
</p>
<p>
Redis strings store sequences of bytes, including text, serialized objects, and binary arrays.
As such, strings are the simplest type of value you can associate with
a Redis key.
They're often used for caching, but they support additional functionality that lets you implement counters and perform bitwise operations, too.
</p>
<p>
Since Redis keys are strings, when we use the string type as a value too,
we are mapping a string to another string. The string data type is useful
for a number of use cases, like caching HTML fragments or pages.
</p>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="set_tutorial-stepset_get">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_set_tutorial-stepset_get" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl"> > SET bike:1 Deimos
</span></span><span class="line hl"><span class="cl"> OK
</span></span><span class="line hl"><span class="cl"> > GET bike:1
</span></span><span class="line hl"><span class="cl"> "Deimos"</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_set_tutorial-stepset_get" title="Open example">
Python
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">"""
</span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for String doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/strings/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># None</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">))</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mset</span><span class="p">({</span><span class="s2">"bike:1"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">:</span> <span class="s2">"Ares"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">:</span> <span class="s2">"Vanth"</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mget</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># ['Deimos', 'Ares', 'Vanth']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># 1</span>
</span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># 11</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_set_tutorial-stepset_get" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_string.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_set_tutorial-stepset_get" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'NX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// null
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">));</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'XX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mSet</span><span class="p">([</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"Ares"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"Vanth"</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mGet</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// ['Deimos', 'Ares', 'Vanth']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incrBy</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_set_tutorial-stepset_get" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-string.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_set_tutorial-stepset_get" title="Open example">
Java
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.params.SetParams</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Arrays</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">StringExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">))</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setnx</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// 0 (because key already exists)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">));</span> <span class="c1">// Deimos (value is unchanged)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">,</span> <span class="n">SetParams</span><span class="o">.</span><span class="na">setParams</span><span class="o">().</span><span class="na">xx</span><span class="o">());</span> <span class="c1">// set the value to "bike" if it
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// already
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// exists
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mset</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"Ares"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"Vanth"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mget</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// [Deimos, Ares, Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="s">"0"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incr</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incrBy</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_set_tutorial-stepset_get" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/StringExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_set_tutorial-stepset_get" title="Open example">
Go
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_set_get</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setnx_xx</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// >>> false
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_mset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// >>> [Deimos Ares Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_incr</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="s">"0"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Incr</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">IncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// >>> 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_set_tutorial-stepset_get" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/string_example_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_set_tutorial-stepset_get" name="set_tutorial-stepset_get" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_set_tutorial-stepset_get" title="Open example">
C#
</label>
<div aria-labelledby="tab-set_tutorial-stepset_get" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_set_tutorial-stepset_get" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">StringSnippets</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">redis</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">NotExists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// false</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">Exists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="k">new</span> <span class="n">KeyValuePair</span><span class="p"><</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// 1</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_set_tutorial-stepset_get')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_set_tutorial-stepset_get" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/StringSnippets.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
As you can see using the
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
and the
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
commands are the way we set
and retrieve a string value. Note that
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
will replace any existing value
already stored into the key, in the case that the key already exists, even if
the key is associated with a non-string value. So
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
performs an assignment.
</p>
<p>
Values can be strings (including binary data) of every kind, for instance you
can store a jpeg image inside a value. A value can't be bigger than 512 MB.
</p>
<p>
The
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
command has interesting options, that are provided as additional
arguments. For example, I may ask
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
to fail if the key already exists,
or the opposite, that it only succeed if the key already exists:
</p>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="set_tutorial-stepsetnx_xx">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_set_tutorial-stepsetnx_xx" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl"> > set bike:1 bike nx
</span></span><span class="line hl"><span class="cl"> (nil)
</span></span><span class="line hl"><span class="cl"> > set bike:1 bike xx
</span></span><span class="line hl"><span class="cl"> OK</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_set_tutorial-stepsetnx_xx" title="Open example">
Python
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">"""
</span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for String doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/strings/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># None</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">))</span> <span class="c1"># Deimos</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mset</span><span class="p">({</span><span class="s2">"bike:1"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">:</span> <span class="s2">"Ares"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">:</span> <span class="s2">"Vanth"</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mget</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># ['Deimos', 'Ares', 'Vanth']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># 1</span>
</span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># 11</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_set_tutorial-stepsetnx_xx" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_string.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_set_tutorial-stepsetnx_xx" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'NX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// null
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">));</span> <span class="c1">// Deimos
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'XX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mSet</span><span class="p">([</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"Ares"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"Vanth"</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mGet</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// ['Deimos', 'Ares', 'Vanth']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incrBy</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_set_tutorial-stepsetnx_xx" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-string.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_set_tutorial-stepsetnx_xx" title="Open example">
Java
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.params.SetParams</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Arrays</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">StringExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">))</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">Long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setnx</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// 0 (because key already exists)
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">));</span> <span class="c1">// Deimos (value is unchanged)
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">,</span> <span class="n">SetParams</span><span class="o">.</span><span class="na">setParams</span><span class="o">().</span><span class="na">xx</span><span class="o">());</span> <span class="c1">// set the value to "bike" if it
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// already
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="c1">// exists
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mset</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"Ares"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"Vanth"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mget</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// [Deimos, Ares, Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="s">"0"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incr</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incrBy</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_set_tutorial-stepsetnx_xx" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/StringExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_set_tutorial-stepsetnx_xx" title="Open example">
Go
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_set_get</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setnx_xx</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// >>> false
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_mset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// >>> [Deimos Ares Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_incr</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="s">"0"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Incr</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">IncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// >>> 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_set_tutorial-stepsetnx_xx" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/string_example_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_set_tutorial-stepsetnx_xx" name="set_tutorial-stepsetnx_xx" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_set_tutorial-stepsetnx_xx" title="Open example">
C#
</label>
<div aria-labelledby="tab-set_tutorial-stepsetnx_xx" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_set_tutorial-stepsetnx_xx" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">StringSnippets</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">redis</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">NotExists</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// false</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">));</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">Exists</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="k">new</span> <span class="n">KeyValuePair</span><span class="p"><</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// 1</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_set_tutorial-stepsetnx_xx')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_set_tutorial-stepsetnx_xx" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/StringSnippets.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
There are a number of other commands for operating on strings. For example
the
<a href="/docs/latest/commands/getset/">
<code>
GETSET
</code>
</a>
command sets a key to a new value, returning the old value as the
result. You can use this command, for example, if you have a
system that increments a Redis key using
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
every time your web site receives a new visitor. You may want to collect this
information once every hour, without losing a single increment.
You can
<a href="/docs/latest/commands/getset/">
<code>
GETSET
</code>
</a>
the key, assigning it the new value of "0" and reading the
old value back.
</p>
<p>
The ability to set or retrieve the value of multiple keys in a single
command is also useful for reduced latency. For this reason there are
the
<a href="/docs/latest/commands/mset/">
<code>
MSET
</code>
</a>
and
<a href="/docs/latest/commands/mget/">
<code>
MGET
</code>
</a>
commands:
</p>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="set_tutorial-stepmset">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_set_tutorial-stepmset" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl"> > mset bike:1 "Deimos" bike:2 "Ares" bike:3 "Vanth"
</span></span><span class="line hl"><span class="cl"> OK
</span></span><span class="line hl"><span class="cl"> > mget bike:1 bike:2 bike:3
</span></span><span class="line hl"><span class="cl"> 1) "Deimos"
</span></span><span class="line hl"><span class="cl"> 2) "Ares"
</span></span><span class="line hl"><span class="cl"> 3) "Vanth"</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_set_tutorial-stepmset" title="Open example">
Python
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">"""
</span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for String doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/strings/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># None</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">))</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mset</span><span class="p">({</span><span class="s2">"bike:1"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">:</span> <span class="s2">"Ares"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">:</span> <span class="s2">"Vanth"</span><span class="p">})</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mget</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">])</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># ['Deimos', 'Ares', 'Vanth']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># 1</span>
</span></span><span class="line"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># 11</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_set_tutorial-stepmset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_string.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_set_tutorial-stepmset" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'NX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// null
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">));</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'XX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mSet</span><span class="p">([</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">],</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"Ares"</span><span class="p">],</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">[</span><span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"Vanth"</span><span class="p">]</span>
</span></span><span class="line hl"><span class="cl"><span class="p">]);</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mGet</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">]);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// ['Deimos', 'Ares', 'Vanth']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incrBy</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_set_tutorial-stepmset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-string.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_set_tutorial-stepmset" title="Open example">
Java
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.params.SetParams</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Arrays</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">StringExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">))</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setnx</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// 0 (because key already exists)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">));</span> <span class="c1">// Deimos (value is unchanged)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">,</span> <span class="n">SetParams</span><span class="o">.</span><span class="na">setParams</span><span class="o">().</span><span class="na">xx</span><span class="o">());</span> <span class="c1">// set the value to "bike" if it
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// already
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// exists
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mset</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"Ares"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"Vanth"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mget</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// [Deimos, Ares, Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="s">"0"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incr</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">Long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incrBy</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_set_tutorial-stepmset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/StringExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_set_tutorial-stepmset" title="Open example">
Go
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_set_get</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setnx_xx</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// >>> false
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_mset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// >>> [Deimos Ares Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_incr</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="s">"0"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Incr</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">IncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// >>> 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_set_tutorial-stepmset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/string_example_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_set_tutorial-stepmset" name="set_tutorial-stepmset" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_set_tutorial-stepmset" title="Open example">
C#
</label>
<div aria-labelledby="tab-set_tutorial-stepmset" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_set_tutorial-stepmset" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">StringSnippets</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">redis</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">NotExists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// false</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">Exists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="k">new</span> <span class="n">KeyValuePair</span><span class="p"><</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>[]</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="k">new</span> <span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">});</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// 1</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">10</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_set_tutorial-stepmset')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_set_tutorial-stepmset" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/StringSnippets.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
When
<a href="/docs/latest/commands/mget/">
<code>
MGET
</code>
</a>
is used, Redis returns an array of values.
</p>
<h3 id="strings-as-counters">
Strings as counters
</h3>
<p>
Even if strings are the basic values of Redis, there are interesting operations
you can perform with them. For instance, one is atomic increment:
</p>
<div class="codetabs cli group flex justify-start items-center flex-wrap box-border rounded-lg mt-0 mb-0 mx-auto bg-slate-900" id="set_tutorial-stepincr">
<input checked="" class="radiotab w-0 h-0" data-lang="redis-cli" id="redis-cli_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="redis-cli_set_tutorial-stepincr" title="Open example">
>_ Redis CLI
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_redis-cli_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-plaintext" data-lang="plaintext"><span class="line hl"><span class="cl"> > set total_crashes 0
</span></span><span class="line hl"><span class="cl"> OK
</span></span><span class="line hl"><span class="cl"> > incr total_crashes
</span></span><span class="line hl"><span class="cl"> (integer) 1
</span></span><span class="line hl"><span class="cl"> > incrby total_crashes 10
</span></span><span class="line hl"><span class="cl"> (integer) 11</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_redis-cli_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<div class="flex-1 text-xs text-white overflow-ellipsis">
Are you tired of using redis-cli? Try Redis Insight - the developer GUI for Redis.
</div>
<div class="text-right">
<a class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.com/redis-enterprise/redis-insight/" tabindex="1" title="Get Redis Insight">
<svg class="w-4 h-4 mr-1" fill="none" height="14" viewbox="0 0 14 14" width="14" xmlns="http://www.w3.org/2000/svg">
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5">
</path>
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5">
</path>
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5">
</path>
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171">
</path>
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171">
</path>
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5">
</path>
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171">
</path>
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5">
</path>
</svg>
<span>
Get Redis Insight
</span>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="python" id="Python_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Python_set_tutorial-stepincr" title="Open example">
Python
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_Python_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-python" data-lang="python"><span class="line"><span class="cl"><span class="s2">"""
</span></span></span><span class="line"><span class="cl"><span class="s2">Code samples for String doc pages:
</span></span></span><span class="line"><span class="cl"><span class="s2"> https://redis.io/docs/latest/develop/data-types/strings/
</span></span></span><span class="line"><span class="cl"><span class="s2">"""</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">r</span> <span class="o">=</span> <span class="n">redis</span><span class="o">.</span><span class="n">Redis</span><span class="p">(</span><span class="n">decode_responses</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res1</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res1</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res2</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res2</span><span class="p">)</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res3</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">nx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res3</span><span class="p">)</span> <span class="c1"># None</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">))</span> <span class="c1"># Deimos</span>
</span></span><span class="line"><span class="cl"><span class="n">res4</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="n">xx</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res4</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">res5</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mset</span><span class="p">({</span><span class="s2">"bike:1"</span><span class="p">:</span> <span class="s2">"Deimos"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">:</span> <span class="s2">"Ares"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">:</span> <span class="s2">"Vanth"</span><span class="p">})</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res5</span><span class="p">)</span> <span class="c1"># True</span>
</span></span><span class="line"><span class="cl"><span class="n">res6</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">mget</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">])</span>
</span></span><span class="line"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res6</span><span class="p">)</span> <span class="c1"># ['Deimos', 'Ares', 'Vanth']</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="n">r</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res7</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res7</span><span class="p">)</span> <span class="c1"># 1</span>
</span></span><span class="line hl"><span class="cl"><span class="n">res8</span> <span class="o">=</span> <span class="n">r</span><span class="o">.</span><span class="n">incrby</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"><span class="nb">print</span><span class="p">(</span><span class="n">res8</span><span class="p">)</span> <span class="c1"># 11</span>
</span></span><span class="line"><span class="cl">
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Python_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Python_set_tutorial-stepincr" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/python/redis-py/" tabindex="1" title="Quick-Start">
Python Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/redis-py/tree/master/doctests/dt_string.py" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="javascript" id="Nodejs_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Nodejs_set_tutorial-stepincr" title="Open example">
Node.js
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_Nodejs_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="kr">import</span> <span class="nx">assert</span> <span class="nx">from</span> <span class="s1">'assert'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">createClient</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'redis'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">createClient</span><span class="p">();</span>
</span></span><span class="line"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">connect</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res1</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res1</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res2</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res2</span><span class="p">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res3</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'NX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res3</span><span class="p">);</span> <span class="c1">// null
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">));</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res4</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike"</span><span class="p">,</span> <span class="p">{</span><span class="s1">'XX'</span><span class="o">:</span> <span class="kc">true</span><span class="p">});</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res4</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">const</span> <span class="nx">res5</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mSet</span><span class="p">([</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"Deimos"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"Ares"</span><span class="p">],</span>
</span></span><span class="line"><span class="cl"> <span class="p">[</span><span class="s2">"bike:3"</span><span class="p">,</span> <span class="s2">"Vanth"</span><span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="p">]);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res5</span><span class="p">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res6</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">mGet</span><span class="p">([</span><span class="s2">"bike:1"</span><span class="p">,</span> <span class="s2">"bike:2"</span><span class="p">,</span> <span class="s2">"bike:3"</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res6</span><span class="p">);</span> <span class="c1">// ['Deimos', 'Ares', 'Vanth']
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"><span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="kr">const</span> <span class="nx">res7</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incr</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res7</span><span class="p">);</span> <span class="c1">// 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span><span class="kr">const</span> <span class="nx">res8</span> <span class="o">=</span> <span class="kr">await</span> <span class="nx">client</span><span class="p">.</span><span class="nx">incrBy</span><span class="p">(</span><span class="s2">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">res8</span><span class="p">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Nodejs_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Nodejs_set_tutorial-stepincr" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/nodejs/" tabindex="1" title="Quick-Start">
Node.js Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/node-redis/tree/emb-examples/doctests/dt-string.js" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="java" id="Java_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Java_set_tutorial-stepincr" title="Open example">
Java
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_Java_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">io.redis.examples</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.UnifiedJedis</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">redis.clients.jedis.params.SetParams</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.ArrayList</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.Arrays</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">StringExample</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kt">void</span> <span class="nf">run</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">try</span> <span class="o">(</span><span class="n">UnifiedJedis</span> <span class="n">jedis</span> <span class="o">=</span> <span class="k">new</span> <span class="n">UnifiedJedis</span><span class="o">(</span><span class="s">"redis://localhost:6379"</span><span class="o">))</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res1</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res1</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res2</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res2</span><span class="o">);</span> <span class="c1">// Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">Long</span> <span class="n">res3</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">setnx</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res3</span><span class="o">);</span> <span class="c1">// 0 (because key already exists)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">jedis</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">));</span> <span class="c1">// Deimos (value is unchanged)
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">String</span> <span class="n">res4</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike"</span><span class="o">,</span> <span class="n">SetParams</span><span class="o">.</span><span class="na">setParams</span><span class="o">().</span><span class="na">xx</span><span class="o">());</span> <span class="c1">// set the value to "bike" if it
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// already
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="c1">// exists
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res4</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="n">String</span> <span class="n">res5</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mset</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"Deimos"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"Ares"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">,</span> <span class="s">"Vanth"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res5</span><span class="o">);</span> <span class="c1">// OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="n">List</span><span class="o"><</span><span class="n">String</span><span class="o">></span> <span class="n">res6</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">mget</span><span class="o">(</span><span class="s">"bike:1"</span><span class="o">,</span> <span class="s">"bike:2"</span><span class="o">,</span> <span class="s">"bike:3"</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res6</span><span class="o">);</span> <span class="c1">// [Deimos, Ares, Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">jedis</span><span class="o">.</span><span class="na">set</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="s">"0"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Long</span> <span class="n">res7</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incr</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res7</span><span class="o">);</span> <span class="c1">// 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span> <span class="n">Long</span> <span class="n">res8</span> <span class="o">=</span> <span class="n">jedis</span><span class="o">.</span><span class="na">incrBy</span><span class="o">(</span><span class="s">"total_crashes"</span><span class="o">,</span> <span class="mi">10</span><span class="o">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">res8</span><span class="o">);</span> <span class="c1">// 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Java_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Java_set_tutorial-stepincr" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/java/jedis/" tabindex="1" title="Quick-Start">
Java Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/jedis/tree/master/src/test/java/io/redis/examples/StringExample.java" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="go" id="Go_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Go_set_tutorial-stepincr" title="Open example">
Go
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_Go_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-go" data-lang="go"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nx">example_commands_test</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="p">(</span>
</span></span><span class="line"><span class="cl"> <span class="s">"context"</span>
</span></span><span class="line"><span class="cl"> <span class="s">"fmt"</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="s">"github.com/redis/go-redis/v9"</span>
</span></span><span class="line"><span class="cl"><span class="p">)</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_set_get</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res1</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res1</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res2</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res2</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_setnx_xx</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res3</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetNX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res3</span><span class="p">)</span> <span class="c1">// >>> false
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res4</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Get</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res4</span><span class="p">)</span> <span class="c1">// >>> Deimos
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res5</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">SetXX</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res5</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_mset</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">res6</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MSet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res6</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"> <span class="nx">res7</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">MGet</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res7</span><span class="p">)</span> <span class="c1">// >>> [Deimos Ares Vanth]
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">func</span> <span class="nf">ExampleClient_incr</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">ctx</span> <span class="o">:=</span> <span class="nx">context</span><span class="p">.</span><span class="nf">Background</span><span class="p">()</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="nx">rdb</span> <span class="o">:=</span> <span class="nx">redis</span><span class="p">.</span><span class="nf">NewClient</span><span class="p">(</span><span class="o">&</span><span class="nx">redis</span><span class="p">.</span><span class="nx">Options</span><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Addr</span><span class="p">:</span> <span class="s">"localhost:6379"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nx">Password</span><span class="p">:</span> <span class="s">""</span><span class="p">,</span> <span class="c1">// no password docs
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="nx">DB</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span> <span class="c1">// use default DB
</span></span></span><span class="line"><span class="cl"><span class="c1"></span> <span class="p">})</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">res8</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Set</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="s">"0"</span><span class="p">,</span> <span class="mi">0</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res8</span><span class="p">)</span> <span class="c1">// >>> OK
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res9</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">Incr</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res9</span><span class="p">)</span> <span class="c1">// >>> 1
</span></span></span><span class="line hl"><span class="cl"><span class="c1"></span>
</span></span><span class="line hl"><span class="cl"> <span class="nx">res10</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">rdb</span><span class="p">.</span><span class="nf">IncrBy</span><span class="p">(</span><span class="nx">ctx</span><span class="p">,</span> <span class="s">"total_crashes"</span><span class="p">,</span> <span class="mi">10</span><span class="p">).</span><span class="nf">Result</span><span class="p">()</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="k">if</span> <span class="nx">err</span> <span class="o">!=</span> <span class="kc">nil</span> <span class="p">{</span>
</span></span><span class="line hl"><span class="cl"> <span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span>
</span></span><span class="line hl"><span class="cl"> <span class="p">}</span>
</span></span><span class="line hl"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="nx">fmt</span><span class="p">.</span><span class="nf">Println</span><span class="p">(</span><span class="nx">res10</span><span class="p">)</span> <span class="c1">// >>> 11
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Go_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Go_set_tutorial-stepincr" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/go/" tabindex="1" title="Quick-Start">
Go Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/go-redis/tree/master/doctests/string_example_test.go" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
<input class="radiotab w-0 h-0" data-lang="dotnet" id="Csharp_set_tutorial-stepincr" name="set_tutorial-stepincr" tabindex="1" type="radio"/>
<label class="justify-left label ml-4 pt-3.5 px-3 pb-1 cursor-pointer text-sm text-center bg-redis-ink-900 hover:text-redis-red-600 rounded rounded-mx transition duration-150 ease-in-out" for="Csharp_set_tutorial-stepincr" title="Open example">
C#
</label>
<div aria-labelledby="tab-set_tutorial-stepincr" class="panel order-last hidden w-full mt-0 relative" id="panel_Csharp_set_tutorial-stepincr" role="tabpanel" tabindex="0">
<div class="highlight">
<pre class="chroma"><code class="language-C#" data-lang="C#"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="k">public</span> <span class="k">class</span> <span class="nc">StringSnippets</span>
</span></span><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">public</span> <span class="k">void</span> <span class="n">run</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">redis</span> <span class="p">=</span> <span class="n">ConnectionMultiplexer</span><span class="p">.</span><span class="n">Connect</span><span class="p">(</span><span class="s">"localhost:6379"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">db</span> <span class="p">=</span> <span class="n">redis</span><span class="p">.</span><span class="n">GetDatabase</span><span class="p">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res1</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res1</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res2</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res2</span><span class="p">);</span> <span class="c1">// Deimos</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res3</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">NotExists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res3</span><span class="p">);</span> <span class="c1">// false</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">));</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res4</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike"</span><span class="p">,</span> <span class="n">when</span><span class="p">:</span> <span class="n">When</span><span class="p">.</span><span class="n">Exists</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res4</span><span class="p">);</span> <span class="c1">// true</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res5</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="k">new</span> <span class="n">KeyValuePair</span><span class="p"><</span><span class="n">RedisKey</span><span class="p">,</span> <span class="n">RedisValue</span><span class="p">>[]</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">new</span> <span class="p">(</span><span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"Deimos"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"Ares"</span><span class="p">),</span> <span class="k">new</span><span class="p">(</span><span class="s">"bike:3"</span><span class="p">,</span> <span class="s">"Vanth"</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res5</span><span class="p">);</span>
</span></span><span class="line"><span class="cl"> <span class="kt">var</span> <span class="n">res6</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringGet</span><span class="p">(</span><span class="k">new</span> <span class="n">RedisKey</span><span class="p">[]</span> <span class="p">{</span> <span class="s">"bike:1"</span><span class="p">,</span> <span class="s">"bike:2"</span><span class="p">,</span> <span class="s">"bike:3"</span> <span class="p">});</span>
</span></span><span class="line"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res6</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line hl"><span class="cl"> <span class="n">db</span><span class="p">.</span><span class="n">StringSet</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">0</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res7</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res7</span><span class="p">);</span> <span class="c1">// 1</span>
</span></span><span class="line hl"><span class="cl"> <span class="kt">var</span> <span class="n">res8</span> <span class="p">=</span> <span class="n">db</span><span class="p">.</span><span class="n">StringIncrement</span><span class="p">(</span><span class="s">"total_crashes"</span><span class="p">,</span> <span class="m">10</span><span class="p">);</span>
</span></span><span class="line hl"><span class="cl"> <span class="n">Console</span><span class="p">.</span><span class="n">WriteLine</span><span class="p">(</span><span class="n">res8</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span></span></span></code></pre>
</div>
<button class="clipboard-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-10 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="copyCodeToClipboard('#panel_Csharp_set_tutorial-stepincr')" tabindex="1" title="Copy to clipboard">
<svg fill="currentColor" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M9 43.95q-1.2 0-2.1-.9-.9-.9-.9-2.1V10.8h3v30.15h23.7v3Zm6-6q-1.2 0-2.1-.9-.9-.9-.9-2.1v-28q0-1.2.9-2.1.9-.9 2.1-.9h22q1.2 0 2.1.9.9.9.9 2.1v28q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h22v-28H15v28Zm0 0v-28 28Z">
</path>
</svg>
<div class="tooltip relative inline-block">
<span class="tooltiptext hidden bg-slate-200 rounded rounded-mx text-slate-800 text-center text-xs p-1 absolute right-6 bottom-4">
Copied!
</span>
</div>
</button>
<button aria-controls="panel_Csharp_set_tutorial-stepincr" class="visibility-button text-neutral-400 hover:text-slate-100 bg-slate-600 absolute -top-8 right-2 h-7 w-7 mr-2 mt-2 p-1 rounded rounded-mx" onclick="toggleVisibleLines(this)" tabindex="1" title="Toggle visibility">
<svg class="hidden" fill="currentColor" id="visibility-off" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="m31.45 27.05-2.2-2.2q1.3-3.55-1.35-5.9-2.65-2.35-5.75-1.2l-2.2-2.2q.85-.55 1.9-.8 1.05-.25 2.15-.25 3.55 0 6.025 2.475Q32.5 19.45 32.5 23q0 1.1-.275 2.175-.275 1.075-.775 1.875Zm6.45 6.45-2-2q2.45-1.8 4.275-4.025Q42 25.25 42.85 23q-2.5-5.55-7.5-8.775Q30.35 11 24.5 11q-2.1 0-4.3.4-2.2.4-3.45.95L14.45 10q1.75-.8 4.475-1.4Q21.65 8 24.25 8q7.15 0 13.075 4.075Q43.25 16.15 46 23q-1.3 3.2-3.35 5.85-2.05 2.65-4.75 4.65Zm2.9 11.3-8.4-8.25q-1.75.7-3.95 1.075T24 38q-7.3 0-13.25-4.075T2 23q1-2.6 2.775-5.075T9.1 13.2L2.8 6.9l2.1-2.15L42.75 42.6ZM11.15 15.3q-1.85 1.35-3.575 3.55Q5.85 21.05 5.1 23q2.55 5.55 7.675 8.775Q17.9 35 24.4 35q1.65 0 3.25-.2t2.4-.6l-3.2-3.2q-.55.25-1.35.375T24 31.5q-3.5 0-6-2.45T15.5 23q0-.75.125-1.5T16 20.15Zm15.25 7.1Zm-5.8 2.9Z">
</path>
</svg>
<svg fill="currentColor" id="visibility-on" viewbox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<path d="M24 31.5q3.55 0 6.025-2.475Q32.5 26.55 32.5 23q0-3.55-2.475-6.025Q27.55 14.5 24 14.5q-3.55 0-6.025 2.475Q15.5 19.45 15.5 23q0 3.55 2.475 6.025Q20.45 31.5 24 31.5Zm0-2.9q-2.35 0-3.975-1.625T18.4 23q0-2.35 1.625-3.975T24 17.4q2.35 0 3.975 1.625T29.6 23q0 2.35-1.625 3.975T24 28.6Zm0 9.4q-7.3 0-13.2-4.15Q4.9 29.7 2 23q2.9-6.7 8.8-10.85Q16.7 8 24 8q7.3 0 13.2 4.15Q43.1 16.3 46 23q-2.9 6.7-8.8 10.85Q31.3 38 24 38Zm0-15Zm0 12q6.05 0 11.125-3.275T42.85 23q-2.65-5.45-7.725-8.725Q30.05 11 24 11t-11.125 3.275Q7.8 17.55 5.1 23q2.7 5.45 7.775 8.725Q17.95 35 24 35Z">
</path>
</svg>
</button>
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible">
<a class="rounded rounded-mx px-3 py-1 text-white text-xs hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none focus:ring-2 focus:white focus:border-slate-500" href="https://redis.io/docs/latest/develop/connect/clients/dotnet/" tabindex="1" title="Quick-Start">
C# Quick-Start
</a>
<div class="w-1/2">
</div>
<div class="flex-1 text-right">
<a class="button text-neutral-400 hover:text-slate-100 h-6 w-6 p-1" href="https://github.com/redis/NRedisStack/tree/master/tests/Doc/StringSnippets.cs" tabindex="1" title="Improve this code example">
<svg fill="github" height="16" viewbox="0 0 18 16" width="18" xmlns="http://www.w3.org/2000/svg">
<path clip-rule="evenodd" d="M8.99953 1.43397e-06C7.09918 -0.000897921 5.26058 0.674713 3.81295 1.90585C2.36533 3.13699 1.40324 4.84324 1.09896 6.71907C0.794684 8.5949 1.1681 10.5178 2.15233 12.1434C3.13657 13.769 4.66734 14.9912 6.47053 15.591C6.87053 15.664 7.01653 15.417 7.01653 15.205C7.01653 15.015 7.00953 14.512 7.00553 13.845C4.78053 14.328 4.31053 12.772 4.31053 12.772C4.16325 12.2887 3.84837 11.8739 3.42253 11.602C2.69653 11.102 3.47753 11.116 3.47753 11.116C3.73043 11.1515 3.97191 11.2442 4.18365 11.3869C4.39539 11.5297 4.57182 11.7189 4.69953 11.94C4.80755 12.1377 4.95378 12.3119 5.12972 12.4526C5.30567 12.5933 5.50782 12.6976 5.72442 12.7595C5.94103 12.8214 6.16778 12.8396 6.39148 12.813C6.61519 12.7865 6.83139 12.7158 7.02753 12.605C7.06381 12.1992 7.24399 11.8197 7.53553 11.535C5.75953 11.335 3.89153 10.647 3.89153 7.581C3.88005 6.78603 4.17513 6.01716 4.71553 5.434C4.47318 4.74369 4.50322 3.98693 4.79953 3.318C4.79953 3.318 5.47053 3.103 6.99953 4.138C8.31074 3.77905 9.69432 3.77905 11.0055 4.138C12.5325 3.103 13.2055 3.318 13.2055 3.318C13.5012 3.9877 13.5294 4.74513 13.2845 5.435C13.8221 6.01928 14.114 6.78817 14.0995 7.582C14.0995 10.655 12.2285 11.332 10.4465 11.53C10.6375 11.724 10.7847 11.9566 10.8784 12.2123C10.972 12.4679 11.0099 12.7405 10.9895 13.012C10.9895 14.081 10.9795 14.944 10.9795 15.206C10.9795 15.42 11.1235 15.669 11.5295 15.591C13.3328 14.9911 14.8636 13.7689 15.8479 12.1432C16.8321 10.5175 17.2054 8.59447 16.901 6.71858C16.5966 4.84268 15.6343 3.13642 14.1865 1.90536C12.7387 0.674306 10.9 -0.0011359 8.99953 1.43397e-06Z" fill="white" fill-rule="evenodd">
</path>
</svg>
</a>
</div>
</div>
</div>
</div>
<p>
The
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
command parses the string value as an integer,
increments it by one, and finally sets the obtained value as the new value.
There are other similar commands like
<a href="/docs/latest/commands/incrby/">
<code>
INCRBY
</code>
</a>
,
<a href="/docs/latest/commands/decr/">
<code>
DECR
</code>
</a>
and
<a href="/docs/latest/commands/decrby/">
<code>
DECRBY
</code>
</a>
. Internally it's
always the same command, acting in a slightly different way.
</p>
<p>
What does it mean that INCR is atomic?
That even multiple clients issuing INCR against
the same key will never enter into a race condition. For instance, it will never
happen that client 1 reads "10", client 2 reads "10" at the same time, both
increment to 11, and set the new value to 11. The final value will always be
12 and the read-increment-set operation is performed while all the other
clients are not executing a command at the same time.
</p>
<h2 id="limits">
Limits
</h2>
<p>
By default, a single Redis string can be a maximum of 512 MB.
</p>
<h2 id="basic-commands">
Basic commands
</h2>
<h3 id="getting-and-setting-strings">
Getting and setting Strings
</h3>
<ul>
<li>
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
stores a string value.
</li>
<li>
<a href="/docs/latest/commands/setnx/">
<code>
SETNX
</code>
</a>
stores a string value only if the key doesn't already exist. Useful for implementing locks.
</li>
<li>
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
retrieves a string value.
</li>
<li>
<a href="/docs/latest/commands/mget/">
<code>
MGET
</code>
</a>
retrieves multiple string values in a single operation.
</li>
</ul>
<h3 id="managing-counters">
Managing counters
</h3>
<ul>
<li>
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
atomically increments counters stored at a given key by 1.
</li>
<li>
<a href="/docs/latest/commands/incrby/">
<code>
INCRBY
</code>
</a>
atomically increments (and decrements when passing a negative number) counters stored at a given key.
</li>
<li>
Another command exists for floating point counters:
<a href="/docs/latest/commands/incrbyfloat/">
<code>
INCRBYFLOAT
</code>
</a>
.
</li>
</ul>
<h3 id="bitwise-operations">
Bitwise operations
</h3>
<p>
To perform bitwise operations on a string, see the
<a href="/docs/latest/develop/data-types/bitmaps/">
bitmaps data type
</a>
docs.
</p>
<p>
See the
<a href="/docs/latest/commands/?group=string">
complete list of string commands
</a>
.
</p>
<h2 id="performance">
Performance
</h2>
<p>
Most string operations are O(1), which means they're highly efficient.
However, be careful with the
<a href="/docs/latest/commands/substr/">
<code>
SUBSTR
</code>
</a>
,
<a href="/docs/latest/commands/getrange/">
<code>
GETRANGE
</code>
</a>
, and
<a href="/docs/latest/commands/setrange/">
<code>
SETRANGE
</code>
</a>
commands, which can be O(n).
These random-access string commands may cause performance issues when dealing with large strings.
</p>
<h2 id="alternatives">
Alternatives
</h2>
<p>
If you're storing structured data as a serialized string, you may also want to consider Redis
<a href="/docs/latest/develop/data-types/hashes/">
hashes
</a>
or
<a href="/docs/latest/develop/data-types/json/">
JSON
</a>
.
</p>
<h2 id="learn-more">
Learn more
</h2>
<ul>
<li>
<a href="https://www.youtube.com/watch?v=7CUt4yWeRQE">
Redis Strings Explained
</a>
is a short, comprehensive video explainer on Redis strings.
</li>
<li>
<a href="https://university.redis.com/courses/ru101/">
Redis University's RU101
</a>
covers Redis strings in detail.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/data-types/strings/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/jsonschema/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JSON schema requests
</h1>
<p class="text-lg -mt-5 mb-10">
API object JSON schema requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-jsonschema">
GET
</a>
</td>
<td>
<code>
/v1/jsonschema
</code>
</td>
<td>
Get JSON schema of API objects
</td>
</tr>
</tbody>
</table>
<h2 id="get-jsonschema">
Get object JSON schema
</h2>
<pre><code>GET /v1/jsonschema
</code></pre>
<p>
Get the JSON schema of various
<a href="/docs/latest/operate/rs/7.4/references/rest-api/objects/">
Redis Enterprise REST API objects
</a>
.
</p>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /jsonschema?object=bdb
</code></pre>
<h4 id="request-headers">
Request headers
</h4>
<table>
<thead>
<tr>
<th>
Key
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
Host
</td>
<td>
cnm.cluster.fqdn
</td>
<td>
Domain name
</td>
</tr>
<tr>
<td>
Accept
</td>
<td>
application/json
</td>
<td>
Accepted media type
</td>
</tr>
</tbody>
</table>
<h4 id="query-parameters">
Query parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
object
</td>
<td>
string
</td>
<td>
Optional. The API object name: 'cluster', 'node', 'bdb' etc.
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns the JSON schema of the specified API object.
</p>
<h4 id="example-json-body">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"type"</span><span class="p">:</span> <span class="s2">"object"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"description"</span><span class="p">:</span> <span class="s2">"An API object that represents a managed database in the cluster."</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"properties"</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"...."</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"...."</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
Success.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7">
406 Not Acceptable
</a>
</td>
<td>
Invalid object.
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/requests/jsonschema/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/node-metrics/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Node metrics
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the node metrics used with Redis Enterprise Software REST API calls.
</p>
<table>
<thead>
<tr>
<th>
Metric name
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
available_flash
</td>
<td>
float
</td>
<td>
Available flash on the node (bytes)
</td>
</tr>
<tr>
<td>
available_memory
</td>
<td>
float
</td>
<td>
Available RAM on the node (bytes)
</td>
</tr>
<tr>
<td>
avg_latency
</td>
<td>
float
</td>
<td>
Average latency of requests handled by endpoints on the node (micro-sec); returned only when there is traffic
</td>
</tr>
<tr>
<td>
bigstore_free
</td>
<td>
float
</td>
<td>
Free space of backend flash (used by flash DB's BigRedis) (bytes); returned only when BigRedis is enabled
</td>
</tr>
<tr>
<td>
bigstore_iops
</td>
<td>
float
</td>
<td>
Rate of I/O operations against backend flash for all shards which are part of a flash-based DB (BigRedis) on the node (ops/sec); returned only when BigRedis is enabled
</td>
</tr>
<tr>
<td>
bigstore_kv_ops
</td>
<td>
float
</td>
<td>
Rate of value read/write operations against backend flash for all shards which are part of a flash-based DB (BigRedis) on the node (ops/sec); returned only when BigRedis is enabled
</td>
</tr>
<tr>
<td>
bigstore_throughput
</td>
<td>
float
</td>
<td>
Throughput of I/O operations against backend flash for all shards which are part of a flash-based DB (BigRedis) on the node (bytes/sec); returned only when BigRedis is enabled
</td>
</tr>
<tr>
<td>
conns
</td>
<td>
float
</td>
<td>
Number of clients connected to endpoints on the node
</td>
</tr>
<tr>
<td>
cpu_idle
</td>
<td>
float
</td>
<td>
CPU idle time portion (0-1, multiply by 100 to get percent)
</td>
</tr>
<tr>
<td>
cpu_system
</td>
<td>
float
</td>
<td>
CPU time portion spent in kernel (0-1, multiply by 100 to get percent)
</td>
</tr>
<tr>
<td>
cpu_user
</td>
<td>
float
</td>
<td>
CPU time portion spent by users-pace processes (0-1, multiply by 100 to get percent)
</td>
</tr>
<tr>
<td>
cur_aof_rewrites
</td>
<td>
float
</td>
<td>
Number of current AOF rewrites by shards on this node
</td>
</tr>
<tr>
<td>
egress_bytes
</td>
<td>
float
</td>
<td>
Rate of outgoing network traffic to the node (bytes/sec)
</td>
</tr>
<tr>
<td>
ephemeral_storage_avail
</td>
<td>
float
</td>
<td>
Disk space available to Redis Enterprise processes on configured ephemeral disk (bytes)
</td>
</tr>
<tr>
<td>
ephemeral_storage_free
</td>
<td>
float
</td>
<td>
Free disk space on configured ephemeral disk (bytes)
</td>
</tr>
<tr>
<td>
free_memory
</td>
<td>
float
</td>
<td>
Free memory on the node (bytes)
</td>
</tr>
<tr>
<td>
ingress_bytes
</td>
<td>
float
</td>
<td>
Rate of incoming network traffic to the node (bytes/sec)
</td>
</tr>
<tr>
<td>
persistent_storage_avail
</td>
<td>
float
</td>
<td>
Disk space available to Redis Enterprise processes on configured persistent disk (bytes)
</td>
</tr>
<tr>
<td>
persistent_storage_free
</td>
<td>
float
</td>
<td>
Free disk space on configured persistent disk (bytes)
</td>
</tr>
<tr>
<td>
provisional_flash
</td>
<td>
float
</td>
<td>
Amount of flash available for new shards on this node, taking into account overbooking, max Redis servers, reserved flash, and provision and migration thresholds (bytes)
</td>
</tr>
<tr>
<td>
provisional_memory
</td>
<td>
float
</td>
<td>
Amount of RAM available for new shards on this node, taking into account overbooking, max Redis servers, reserved memory, and provision and migration thresholds (bytes)
</td>
</tr>
<tr>
<td>
total_req
</td>
<td>
float
</td>
<td>
Request rate handled by endpoints on the node (ops/sec)
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/rest-api/objects/statistics/node-metrics/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/json.numincrby.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.NUMINCRBY
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.NUMINCRBY key path value</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/json">
JSON 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Increment the number value stored at
<code>
path
</code>
by
<code>
number
</code>
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key to modify.
</p>
</details>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify.
</p>
</details>
<details open="">
<summary>
<code>
value
</code>
</summary>
<p>
is number value to increment.
</p>
</details>
<h2 id="return">
Return
</h2>
<p>
JSON.NUMINCRBY returns a bulk string reply specified as a stringified new value for each path, or
<code>
nil
</code>
, if the matching JSON value is not a number.
For more information about replies, see
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Increment number values
</b>
</summary>
<p>
Create a document.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET doc . <span class="s1">'{"a":"b","b":[{"a":2}, {"a":5}, {"a":"c"}]}'</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Increment a value of
<code>
a
</code>
object by 2. The command fails to find a number and returns
<code>
null
</code>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.NUMINCRBY doc $.a <span class="m">2</span>
</span></span><span class="line"><span class="cl"><span class="s2">"[null]"</span></span></span></code></pre>
</div>
<p>
Recursively find and increment a value of all
<code>
a
</code>
objects. The command increments numbers it finds and returns
<code>
null
</code>
for nonnumber values.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.NUMINCRBY doc $..a <span class="m">2</span>
</span></span><span class="line"><span class="cl"><span class="s2">"[null,4,7,null]"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/json.arrindex/">
<code>
JSON.ARRINDEX
</code>
</a>
|
<a href="/docs/latest/commands/json.arrinsert/">
<code>
JSON.ARRINSERT
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/data-types/json/">
RedisJSON
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
Index and search JSON documents
</a>
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.numincrby/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis products
</h1>
<p class="text-lg -mt-5 mb-10">
Operate any Redis, from Redis Enterprise to Redis Cloud
</p>
<nav>
<a href="/docs/latest/operate/rc/">
Redis Cloud
</a>
<p>
The fastest way to set up Redis - a fully managed Redis database on major public cloud services.
</p>
<a href="/docs/latest/operate/rs/">
Redis Enterprise Software
</a>
<p>
The self-managed, enterprise-grade version of Redis.
</p>
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise for Kubernetes
</a>
<p>
The Redis Enterprise operators allows you to use Redis Enterprise for Kubernetes.
</p>
<a href="/docs/latest/operate/oss_and_stack/">
Redis Community Edition and Stack
</a>
<p>
Operate Redis Community Edition and Redis Stack. Redis OSS was renamed Redis Community Edition (CE) with the v7.4 release.
</p>
<a href="/docs/latest/operate/redisinsight/">
Redis Insight
</a>
<p>
Install and manage Redis Insight
</p>
</nav>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/publish/.html | <section class="prose w-full py-12">
<h1 class="command-name">
PUBLISH
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">PUBLISH channel message</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N+M) where N is the number of clients subscribed to the receiving channel and M is the total number of subscribed patterns (by any client).
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@pubsub
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Posts a message to the given channel.
</p>
<p>
In a Redis Cluster clients can publish to every node. The cluster makes sure
that published messages are forwarded as needed, so clients can subscribe to any
channel by connecting to any one of the nodes.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of clients that the message was sent to. Note that in a Redis Cluster, only clients that are connected to the same node as the publishing client are included in the count.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/publish/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/zdiffstore/.html | <section class="prose w-full py-12">
<h1 class="command-name">
ZDIFFSTORE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">ZDIFFSTORE destination numkeys key [key ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
6.2.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(L + (N-K)log(N)) worst case where L is the total number of elements in all the sets, N is the size of the first set, and K is the size of the result set.
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@sortedset
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Computes the difference between the first and all successive input sorted sets
and stores the result in
<code>
destination
</code>
. The total number of input keys is
specified by
<code>
numkeys
</code>
.
</p>
<p>
Keys that do not exist are considered to be empty sets.
</p>
<p>
If
<code>
destination
</code>
already exists, it is overwritten.
</p>
<h2 id="examples">
Examples
</h2>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> ZADD zset1 1 "one"
(integer) 1
redis> ZADD zset1 2 "two"
(integer) 1
redis> ZADD zset1 3 "three"
(integer) 1
redis> ZADD zset2 1 "one"
(integer) 1
redis> ZADD zset2 2 "two"
(integer) 1
redis> ZDIFFSTORE out 2 zset1 zset2
(integer) 1
redis> ZRANGE out 0 -1 WITHSCORES
1) "three"
2) "3"
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of members in the resulting sorted set at
<em>
destination
</em>
.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/zdiffstore/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/config-set/.html | <section class="prose w-full py-12">
<h1 class="command-name">
CONFIG SET
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">CONFIG SET parameter value [parameter value ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) when N is the number of configuration parameters provided
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@admin
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@dangerous
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The
<code>
CONFIG SET
</code>
command is used in order to reconfigure the server at run time
without the need to restart Redis.
You can change both trivial parameters or switch from one to another persistence
option using this command.
</p>
<p>
The list of configuration parameters supported by
<code>
CONFIG SET
</code>
can be obtained
issuing a
<code>
CONFIG GET *
</code>
command, that is the symmetrical command used to obtain
information about the configuration of a running Redis instance.
</p>
<p>
All the configuration parameters set using
<code>
CONFIG SET
</code>
are immediately loaded
by Redis and will take effect starting with the next command executed.
</p>
<p>
All the supported parameters have the same meaning of the equivalent
configuration parameter used in the
<a href="http://github.com/redis/redis/raw/unstable/redis.conf">
redis.conf
</a>
file.
</p>
<p>
Note that you should look at the redis.conf file relevant to the version you're
working with as configuration options might change between versions. The link
above is to the latest development version.
</p>
<p>
It is possible to switch persistence from RDB snapshotting to append-only file
(and the other way around) using the
<code>
CONFIG SET
</code>
command.
See the
<a href="/docs/latest/operate/oss_and_stack/management/persistence/">
persistence page
</a>
for more information.
</p>
<p>
In general what you should know is that setting the
<code>
appendonly
</code>
parameter to
<code>
yes
</code>
will start a background process to save the initial append-only file
(obtained from the in memory data set), and will append all the subsequent
commands on the append-only file, thus obtaining exactly the same effect of a
Redis server that started with AOF turned on since the start.
</p>
<p>
You can have both the AOF enabled with RDB snapshotting if you want, the two
options are not mutually exclusive.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
when the configuration was set properly. Otherwise an error is returned.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Added the ability to set multiple parameters in one call.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/config-set/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/tdigest.info.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.INFO
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.INFO key</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 2.4.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
</dl>
<p>
Returns information and statistics about a t-digest sketch.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for an existing t-digest sketch.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
with information about the sketch (name-value pairs):
</p>
<table>
<thead>
<tr>
<th>
Name
<br/>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
Compression
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
The compression (controllable trade-off between accuracy and memory consumption) of the sketch
</td>
</tr>
<tr>
<td>
<code>
Capacity
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Size of the buffer used for storing the centroids and for the incoming unmerged observations
</td>
</tr>
<tr>
<td>
<code>
Merged nodes
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of merged observations
</td>
</tr>
<tr>
<td>
<code>
Unmerged nodes
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of buffered nodes (uncompressed observations)
</td>
</tr>
<tr>
<td>
<code>
Merged weight
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Weight of values of the merged nodes
</td>
</tr>
<tr>
<td>
<code>
Unmerged weight
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Weight of values of the unmerged nodes (uncompressed observations)
</td>
</tr>
<tr>
<td>
<code>
Observations
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of observations added to the sketch
</td>
</tr>
<tr>
<td>
<code>
Total compressions
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of times this sketch compressed data together
</td>
</tr>
<tr>
<td>
<code>
Memory usage
</code>
</td>
<td>
<a href="/docs/latest/develop/reference/protocol-spec/#integers">
Integer reply
</a>
<br/>
Number of bytes allocated for the sketch
</td>
</tr>
</tbody>
</table>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> TDIGEST.CREATE t
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.INFO t
</span></span><span class="line"><span class="cl"> 1<span class="o">)</span> Compression
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">100</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> Capacity
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">610</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> Merged nodes
</span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl"> 7<span class="o">)</span> Unmerged nodes
</span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl"> 9<span class="o">)</span> Merged weight
</span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl">11<span class="o">)</span> Unmerged weight
</span></span><span class="line"><span class="cl">12<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl">13<span class="o">)</span> Observations
</span></span><span class="line"><span class="cl">14<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl">15<span class="o">)</span> Total compressions
</span></span><span class="line"><span class="cl">16<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">0</span>
</span></span><span class="line"><span class="cl">17<span class="o">)</span> Memory usage
</span></span><span class="line"><span class="cl">18<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">9768</span></span></span></code></pre>
</div>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/tdigest.info/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/getdel/.html | <section class="prose w-full py-12">
<h1 class="command-name">
GETDEL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">GETDEL key</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
6.2.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@string
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@fast
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Get the value of
<code>
key
</code>
and delete the key.
This command is similar to
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
, except for the fact that it also deletes the key on success (if and only if the key's value type is a string).
</p>
<h2 id="examples">
Examples
</h2>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> SET mykey "Hello"
"OK"
redis> GETDEL mykey
"Hello"
redis> GET mykey
(nil)
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the value of the key.
</li>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Nil reply
</a>
: if the key does not exist or if the key's value type is not a string.
</li>
</ul>
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the value of the key.
</li>
<li>
<a href="../../develop/reference/protocol-spec#nulls">
Null reply
</a>
: if the key does not exist or if the key's value type is not a string.
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/getdel/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/latency-doctor/.html | <section class="prose w-full py-12">
<h1 class="command-name">
LATENCY DOCTOR
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">LATENCY DOCTOR</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.8.13
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@admin
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@dangerous
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
The
<code>
LATENCY DOCTOR
</code>
command reports about different latency-related issues and advises about possible remedies.
</p>
<p>
This command is the most powerful analysis tool in the latency monitoring
framework, and is able to provide additional statistical data like the average
period between latency spikes, the median deviation, and a human-readable
analysis of the event. For certain events, like
<code>
fork
</code>
, additional information
is provided, like the rate at which the system forks processes.
</p>
<p>
This is the output you should post in the Redis mailing list if you are
looking for help about Latency related issues.
</p>
<h2 id="examples">
Examples
</h2>
<pre tabindex="0"><code>127.0.0.1:6379> latency doctor
Dave, I have observed latency spikes in this Redis instance.
You don't mind talking about it, do you Dave?
1. command: 5 latency spikes (average 300ms, mean deviation 120ms,
period 73.40 sec). Worst all time event 500ms.
I have a few advices for you:
- Your current Slow Log configuration only logs events that are
slower than your configured latency monitor threshold. Please
use 'CONFIG SET slowlog-log-slower-than 1000'.
- Check your Slow Log to understand what are the commands you are
running which are too slow to execute. Please check
http://redis.io/commands/slowlog for more information.
- Deleting, expiring or evicting (because of maxmemory policy)
large objects is a blocking operation. If you have very large
objects that are often deleted, expired, or evicted, try to
fragment those objects into multiple smaller objects.
</code></pre>
<p>
<strong>
Note:
</strong>
the doctor has erratic psychological behaviors, so we recommend interacting with it carefully.
</p>
<p>
For more information refer to the
<a href="/operate/oss_and_stack/management/optimization/latency-monitor.md">
Latency Monitoring Framework page
</a>
.
</p>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: a human readable latency analysis report.
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#verbatim-strings">
Verbatim string reply
</a>
: a human readable latency analysis report.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/latency-doctor/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/json.arrappend/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.ARRAPPEND
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.ARRAPPEND key [path] value [value ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/json">
JSON 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Append the
<code>
json
</code>
values into the array at
<code>
path
</code>
after the last element in it
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key to modify.
</p>
</details>
<details open="">
<summary>
<code>
value
</code>
</summary>
<p>
is one or more values to append to one or more arrays.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
About using strings with JSON commands:
</div>
To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example:
<code>
'"silver"'
</code>
. For more detailed use, see
<a href="#examples">
Examples
</a>
.
</div>
</div>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<code>
JSON.ARRAPEND
</code>
returns an
<a href="/docs/latest/develop/reference/protocol-spec#resp-arrays">
array
</a>
of integer replies for each path, the array's new size, or
<code>
nil
</code>
, if the matching JSON value is not an array.
For more information about replies, see
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<details open="">
<summary>
<b>
Add a new color to a list of product colors
</b>
</summary>
<p>
Create a document for noise-cancelling headphones in black and silver colors.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET item:1 $ <span class="s1">'{"name":"Noise-cancelling Bluetooth headphones","description":"Wireless Bluetooth headphones with noise-cancelling technology","connection":{"wireless":true,"type":"Bluetooth"},"price":99.98,"stock":25,"colors":["black","silver"]}'</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<p>
Add color
<code>
blue
</code>
to the end of the
<code>
colors
</code>
array.
<code>
JSON.ARRAPEND
</code>
returns the array's new size.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.ARRAPPEND item:1 $.colors <span class="s1">'"blue"'</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">3</span></span></span></code></pre>
</div>
<p>
Return the new length of the
<code>
colors
</code>
array.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.GET item:1
</span></span><span class="line"><span class="cl"><span class="s2">"{\"name\":\"Noise-cancelling Bluetooth headphones\",\"description\":\"Wireless Bluetooth headphones with noise-cancelling technology\",\"connection\":{\"wireless\":true,\"type\":\"Bluetooth\"},\"price\":99.98,\"stock\":25,\"colors\":[\"black\",\"silver\",\"blue\"]}"</span></span></span></code></pre>
</div>
</details>
<h2 id="see-also">
See also
</h2>
<p>
<a href="/docs/latest/commands/json.arrindex/">
<code>
JSON.ARRINDEX
</code>
</a>
|
<a href="/docs/latest/commands/json.arrinsert/">
<code>
JSON.ARRINSERT
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/data-types/json/">
RedisJSON
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
Index and search JSON documents
</a>
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.arrappend/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-dump-support-package/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di dump-support-package
</h1>
<p class="text-lg -mt-5 mb-10">
Dumps Write-behind support package
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di dump-support-package [OPTIONS]
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
loglevel
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--loglevel -log-level
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
rdi_host
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-host
</code>
</li>
</ul>
<p>
Host/IP of Write-behind Database
</p>
</li>
<li>
<p>
<code>
rdi_port
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: <IntRange 1000<=x<=65535>
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-port
</code>
</li>
</ul>
<p>
Port of Write-behind Database
</p>
</li>
<li>
<p>
<code>
rdi_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-password
</code>
</li>
</ul>
<p>
Write-behind Database Password
</p>
</li>
<li>
<p>
<code>
rdi_key
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-key
</code>
</li>
</ul>
<p>
Private key file to authenticate with
</p>
</li>
<li>
<p>
<code>
rdi_cert
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-cert
</code>
</li>
</ul>
<p>
Client certificate file to authenticate with
</p>
</li>
<li>
<p>
<code>
rdi_cacert
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-cacert
</code>
</li>
</ul>
<p>
CA certificate file to verify with
</p>
</li>
<li>
<p>
<code>
rdi_key_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-key-password
</code>
</li>
</ul>
<p>
Password for unlocking an encrypted private key
</p>
</li>
<li>
<p>
<code>
directory
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
.
</code>
</li>
<li>
Usage:
<code>
--dir
</code>
</li>
</ul>
<p>
Directory where the support file should be generated
</p>
</li>
<li>
<p>
<code>
dump_rejected
</code>
:
</p>
<ul>
<li>
Type: INT
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--dump-rejected
</code>
</li>
</ul>
<p>
Dumps rejected records
</p>
</li>
<li>
<p>
<code>
trace_timeout
</code>
:
</p>
<ul>
<li>
Type: <IntRange 1<=x<=600>
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--trace-timeout
</code>
</li>
</ul>
<p>
Stops the trace after exceeding this timeout (in seconds)
</p>
</li>
<li>
<p>
<code>
max_change_records
</code>
:
</p>
<ul>
<li>
Type:
<intrange x="">
=1>
</intrange>
</li>
<li>
Default:
<code>
10
</code>
</li>
<li>
Usage:
<code>
--max-change-records
</code>
</li>
</ul>
<p>
Maximum traced change records per shard
</p>
</li>
<li>
<p>
<code>
trace_only_rejected
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--trace-only-rejected
</code>
</li>
</ul>
<p>
Trace only rejected change records
</p>
</li>
<li>
<p>
<code>
help
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--help
</code>
</li>
</ul>
<p>
Show this message and exit.
</p>
</li>
</ul>
<h2 id="cli-help">
CLI help
</h2>
<pre tabindex="0"><code>Usage: redis-di dump-support-package [OPTIONS]
Dumps Write-behind support package
Options:
-log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
--rdi-host TEXT Host/IP of Write-behind Database [required]
--rdi-port INTEGER RANGE Port of Write-behind Database [1000<=x<=65535;
required]
--rdi-password TEXT Write-behind Database Password
--rdi-key TEXT Private key file to authenticate with
--rdi-cert TEXT Client certificate file to authenticate with
--rdi-cacert TEXT CA certificate file to verify with
--rdi-key-password TEXT Password for unlocking an encrypted private
key
--dir TEXT Directory where the support file should be
generated [default: .]
--dump-rejected INTEGER Dumps rejected records
--trace-timeout INTEGER RANGE Stops the trace after exceeding this timeout
(in seconds) [1<=x<=600]
--max-change-records INTEGER RANGE
Maximum traced change records per shard
[x>=1]
--trace-only-rejected Trace only rejected change records
--help Show this message and exit.
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-dump-support-package/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/security/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Security
</h1>
<p>
Redis Enterprise Software provides various features to secure your Redis Enterprise Software deployment:
</p>
<table>
<thead>
<tr>
<th>
Login and passwords
</th>
<th>
Users and roles
</th>
<th>
Encryption and TLS
</th>
<th>
Certificates and audit
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-users/login-lockout/">
Password attempts and session timeout
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/">
Cluster and database access explained
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/encryption/tls/enable-tls/">
Enable TLS
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/certificates/create-certificates/">
Create certificates
</a>
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-passwords/password-complexity-rules/">
Password complexity
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/create-users/">
Create users
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/encryption/tls/tls-protocols/">
Configure TLS protocols
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/certificates/monitor-certificates/">
Monitor certificates
</a>
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-passwords/password-expiration/">
Password expiration
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/create-combined-roles/">
Create roles
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/encryption/tls/ciphers/">
Configure cipher suites
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/certificates/updating-certificates/">
Update certificates
</a>
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-users/default-user/">
Default database access
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/redis-acl-overview/">
Redis ACLs
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/encryption/pem-encryption/">
Encrypt private keys on disk
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/certificates/ocsp-stapling/">
Enable OCSP stapling
</a>
</td>
</tr>
<tr>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/manage-passwords/rotate-passwords/">
Rotate user passwords
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/access-control/ldap/">
Integrate with LDAP
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/encryption/internode-encryption/">
Internode encryption
</a>
</td>
<td>
<a href="/docs/latest/operate/rs/7.4/security/audit-events/">
Audit database connections
</a>
</td>
</tr>
</tbody>
</table>
<h2 id="recommended-security-practices">
Recommended security practices
</h2>
<p>
See
<a href="/docs/latest/operate/rs/7.4/security/recommended-security-practices/">
Recommended security practices
</a>
to learn how to protect Redis Enterprise Software.
</p>
<h2 id="redis-trust-center">
Redis Trust Center
</h2>
<p>
Visit our
<a href="https://trust.redis.io/">
Trust Center
</a>
to learn more about Redis security policies. If you find a suspected security bug, you can
<a href="https://hackerone.com/redis-vdp?type=team">
submit a report
</a>
.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/security/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/release-notes/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise Software for Kubernetes release notes
</h1>
<p class="text-lg -mt-5 mb-10">
Redis Enterprise Software for Kubernetes operator release notes.
</p>
<table>
<thead>
<tr>
<th style="text-align:left">
VersionΒ (ReleaseΒ date)
</th>
<th style="text-align:left">
Major changes
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-4-6-releases/">
7.4.6-2
</a>
</td>
<td style="text-align:left">
Releases with support for Redis Enterprise Software 7.4.6.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-4-2-releases/">
7.4.2-2
</a>
</td>
<td style="text-align:left">
Releases with support for Redis Enterprise Software 7.4.2.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/7-2-4-releases/">
7.2.4 releases
</a>
</td>
<td style="text-align:left">
Support for Redis Enterprise 7.2.4, platform support updates, and bug fixes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/6-4-2-releases/">
6.4.2 releases
</a>
</td>
<td style="text-align:left">
Release notes for the 6.4.2 releases of Redis Enterprise Software for Kubernetes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/6-2-18-releases/">
6.2.18 releases
</a>
</td>
<td style="text-align:left">
Release notes for the 6.2.18 releases of Redis Enterprise Software for Kubernetes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-12-1/">
6.2.12-1 (Sept 2022)
</a>
</td>
<td style="text-align:left">
Support added for additional distributions, as well as feature improvements and bug fixes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-10-45-2022-07/">
6.2.10-45 (July 2022)
</a>
</td>
<td style="text-align:left">
Support added for additional distributions as well as some feature improvements.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-10-34-2022-05/">
6.2.10-34 (May 2022)
</a>
</td>
<td style="text-align:left">
Support for REBD specific upgrade policies, memcached type REDBs, and RHEL8 for OpenShift, as well as feature improvements and bug fixes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-10-4-2022-03-copy/">
6.2.10-4 (March 2022)
</a>
</td>
<td style="text-align:left">
Added support for RS 6.2.10 as well as feature improvements and bug fixes.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-15-2022-01/">
6.2.8-15 (January 2022)
</a>
</td>
<td style="text-align:left">
Maintenance release with bug fixes
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-11-2022-01/">
6.2.8-11 (January 2022)
</a>
</td>
<td style="text-align:left">
Support for Istio as ingress controller, K8s 1.22 (AKS, kOps, GKE), OpenShift 4.9
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-2-2021-11/">
6.2.8-2 (November 2021)
</a>
</td>
<td style="text-align:left">
Support for RS 6.2.8, certificate management, and Redis upgrade policy.
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/k8s-6-2-4-1-2021-09/">
6.2.4-1 (September 2021)
</a>
</td>
<td style="text-align:left">
Support for RS 6.2.4 and OpenShift 4.8. Support for K8s 1.19 (EKS and AKS), K8s 1.20 (Rancher, EKS, AKS), K8s 1.21 (GKE and kOps).
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="/docs/latest/operate/kubernetes/release-notes/previous-releases/">
Previous versions
</a>
</td>
<td style="text-align:left">
Release notes for versions of Redis Enterprise for Kubernetes released more than 18 months ago.
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/bf.reserve/.html | <section class="prose w-full py-12">
<h1 class="command-name">
BF.RESERVE
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">BF.RESERVE key error_rate capacity [EXPANSIONΒ expansion]
[NONSCALING]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
</dl>
<p>
Creates an empty Bloom filter with a single sub-filter for the initial specified capacity and with an upper bound
<code>
error_rate
</code>
.
</p>
<p>
By default, the filter auto-scales by creating additional sub-filters when
<code>
capacity
</code>
is reached.
The new sub-filter is created with size of the previous sub-filter multiplied by
<code>
expansion
</code>
.
</p>
<p>
Though the filter can scale up by creating sub-filters, it is recommended to reserve the estimated required
<code>
capacity
</code>
since maintaining and querying
sub-filters requires additional memory (each sub-filter uses an extra bits and hash function) and consume further CPU time than an equivalent filter that had
the right capacity at creation time.
</p>
<p>
The number of hash functions is
<code>
-log(error)/ln(2)^2
</code>
.
The number of bits per item is
<code>
-log(error)/ln(2)
</code>
β 1.44.
</p>
<ul>
<li>
<strong>
1%
</strong>
error rate requires 7 hash functions and 10.08 bits per item.
</li>
<li>
<strong>
0.1%
</strong>
error rate requires 10 hash functions and 14.4 bits per item.
</li>
<li>
<strong>
0.01%
</strong>
error rate requires 14 hash functions and 20.16 bits per item.
</li>
</ul>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key name for the the Bloom filter to be created.
</p>
</details>
<details open="">
<summary>
<code>
error_rate
</code>
</summary>
<p>
The desired probability for false positives. The rate is a decimal value between 0 and 1.
For example, for a desired false positive rate of 0.1% (1 in 1000), error_rate should be set to 0.001.
</p>
</details>
<details open="">
<summary>
<code>
capacity
</code>
</summary>
<p>
The number of entries intended to be added to the filter.
If your filter allows scaling, performance will begin to degrade after adding more items than this number.
The actual degradation depends on how far the limit has been exceeded. Performance degrades linearly with the number of
<code>
sub-filters
</code>
.
</p>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
NONSCALING
</code>
</summary>
<p>
Prevents the filter from creating additional sub-filters if initial capacity is reached.
Non-scaling filters requires slightly less memory than their scaling counterparts. The filter returns an error when
<code>
capacity
</code>
is reached.
</p>
</details>
<details open="">
<summary>
<code>
EXPANSION expansion
</code>
</summary>
<p>
When
<code>
capacity
</code>
is reached, an additional sub-filter is created.
The size of the new sub-filter is the size of the last sub-filter multiplied by
<code>
expansion
</code>
, specified as a positive integer.
</p>
<p>
If the number of elements to be stored in the filter is unknown, you use an
<code>
expansion
</code>
of
<code>
2
</code>
or more to reduce the number of sub-filters.
Otherwise, you use an
<code>
expansion
</code>
of
<code>
1
</code>
to reduce memory consumption. The default value is
<code>
2
</code>
.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
Returns one of these replies:
</p>
<ul>
<li>
<a href="/docs/latest/develop/reference/protocol-spec/#simple-strings">
Simple string reply
</a>
-
<code>
OK
</code>
if filter created successfully
</li>
<li>
[] on error (invalid arguments, key already exists, etc.)
</li>
</ul>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf 0.01 <span class="m">1000</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf 0.01 <span class="m">1000</span>
</span></span><span class="line"><span class="cl"><span class="o">(</span>error<span class="o">)</span> ERR item exists</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf_exp 0.01 <span class="m">1000</span> EXPANSION <span class="m">2</span>
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> BF.RESERVE bf_non 0.01 <span class="m">1000</span> NONSCALING
</span></span><span class="line"><span class="cl">OK</span></span></code></pre>
</div>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bf.reserve/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/synonyms/.html | <section class="prose w-full py-12">
<h1>
Synonym support
</h1>
<p class="text-lg -mt-5 mb-10">
Details on synonym support with Redis Stack
</p>
<p>
Redis Stack supports synonyms. That is, searching for synonym words defined by the synonym data structure.
</p>
<p>
The synonym data structure is a set of groups, each of which contains synonym terms. For example, the following synonym data structure contains three groups, and each group contains three synonym terms:
</p>
<pre tabindex="0"><code>{boy, child, baby}
{girl, child, baby}
{man, person, adult}
</code></pre>
<p>
When these three groups are located inside the synonym data structure, it is possible to search for "child" and receive documents containing "boy", "girl", "child" and "baby".
</p>
<h2 id="the-synonym-search-technique">
The synonym search technique
</h2>
<p>
A simple HashMap is used to map between the terms and the group IDs. During index creation, a check is made to see if the current term appears in the synonym map, and if it does, take all the group IDs that the term belongs to.
</p>
<p>
For each group ID, another record is added to the inverted index called "~<id>" that contains the same information as the term itself. When performing a search, a check is made to see if the searched term appears in the synonym map, and if it does, take all the group IDs the term belongs to. For each group ID, search for "~<id>" and return the combined results. This technique ensures that all the synonyms of a given term will be returned.
</p>
<h2 id="handling-concurrency">
Handling concurrency
</h2>
<p>
Since the indexing is performed in a separate thread, the synonyms map may change during indexing, which in turn may cause data corruption or crashes during indexing or searching. To solve this issue, a read-only copy is created for indexing purposes. The read-only copy is maintained using reference count.
</p>
<p>
As long as the synonyms map does not change, the original synonym map holds a reference to its read-only copy, so it will not be freed. After the data inside the synonyms map has changed, the synonyms map decreses the reference count of its read only copy. This ensures that when all the indexers are done using the read-only copy, it will automatically be freed. This ensures that the next time an indexer asks for a read-only copy, the synonyms map will create a new copy (containing the new data) and return it.
</p>
<h2 id="example">
Example
</h2>
<pre tabindex="0"><code># Create an index
> FT.CREATE idx schema t text
# Create a synonym group
> FT.SYNUPDATE idx group1 hello world
# Insert documents
> HSET foo t hello
(integer) 1
> HSET bar t world
(integer) 1
# Search
> FT.SEARCH idx hello
1) (integer) 2
2) "foo"
3) 1) "t"
2) "hello"
4) "bar"
5) 1) "t"
2) "world"
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/synonyms/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-2-2021-11/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Enterprise for Kubernetes Release Notes 6.2.8-2 (November 2021)
</h1>
<p class="text-lg -mt-5 mb-10">
Support for RS 6.2.8, certificate management, and Redis upgrade policy.
</p>
<h2 id="overview">
Overview
</h2>
<p>
The Redis Enterprise
<a href="https://github.com/RedisLabs/redis-enterprise-k8s-docs/releases/tag/v6.2.8-2">
K8s 6.2.8-2
</a>
release provides support for the
<a href="/docs/latest/operate/rs/release-notes/rs-6-2-8-october-2021/">
Redis Enterprise Software release 6.2.8
</a>
and includes several enhancements and bug fixes.
</p>
<p>
The key new features, bug fixes, and known limitations are described below.
</p>
<h2 id="images">
Images
</h2>
<p>
This release includes the following container images:
</p>
<ul>
<li>
<strong>
Redis Enterprise
</strong>
:
<code>
redislabs/redis:6.2.8-41
</code>
or
<code>
redislabs/redis:6.2.8-41.rhel7-openshift
</code>
</li>
<li>
<strong>
Operator
</strong>
:
<code>
redislabs/operator:6.2.8-2
</code>
</li>
<li>
<strong>
Services Rigger
</strong>
:
<code>
redislabs/k8s-controller:6.2.8-2
</code>
or
<code>
redislabs/services-manager:6.2.8-2
</code>
(on the Red Hat registry)
</li>
</ul>
<h2 id="new-features">
New features
</h2>
<ul>
<li>
Certificate management capabilities through the Redis Enterprise cluster API (RED-61176)
</li>
</ul>
<h2 id="feature-improvements">
Feature improvements
</h2>
<ul>
<li>
Support for managing database ports through the REDB API (RED-48286)
</li>
<li>
Use explicit object instead of wildcard for roles (RED-38013)
</li>
<li>
Advanced use case support for custom attributes for REC stateful set and rigger pods (RED-56502, RED-62550, RED-63426)
</li>
<li>
Services rigger/K8s controller image changed to ubi-minimal lightweight base image (RED-61866)
</li>
<li>
Support for the Redis upgrade policy setting through the REC API (RED-63000)
</li>
</ul>
<h2 id="fixed-bugs">
Fixed bugs
</h2>
<ul>
<li>
Fixed issue of log rotation not working on OpenShift (RED-64726)
</li>
</ul>
<h2 id="known-limitations">
Known limitations
</h2>
<h3 id="large-clusters">
Large clusters
</h3>
<p>
On clusters with more than 9 REC nodes, a Kubernetes upgrade can render the Redis cluster unresponsive in some cases. A fix is available in the 6.4.2-5 release. Upgrade your operator version to 6.4.2-5 or later before upgrading your Kubernetes cluster. (RED-93025)
</p>
<h3 id="long-cluster-names-cause-routes-to-be-rejected--red-25871">
Long cluster names cause routes to be rejected (RED-25871)
</h3>
<p>
A cluster name longer than 20 characters will result in a rejected route configuration because the host part of the domain name will exceed 63 characters. The workaround is to limit cluster name to 20 characters or less.
</p>
<h3 id="cluster-cr-rec-errors-are-not-reported-after-invalid-updates-red-25542">
Cluster CR (REC) errors are not reported after invalid updates (RED-25542)
</h3>
<p>
A cluster CR specification error is not reported if two or more invalid CR resources are updated in sequence.
</p>
<h3 id="an-unreachable-cluster-has-status-running-red-32805">
An unreachable cluster has status running (RED-32805)
</h3>
<p>
When a cluster is in an unreachable state, the state is still
<code>
running
</code>
instead of being reported as an error.
</p>
<h3 id="readiness-probe-incorrect-on-failures-red-39300">
Readiness probe incorrect on failures (RED-39300)
</h3>
<p>
STS Readiness probe does not mark a node as "not ready" when running
<code>
rladmin status
</code>
on node failure.
</p>
<h3 id="role-missing-on-replica-sets-red-39002">
Role missing on replica sets (RED-39002)
</h3>
<p>
The
<code>
redis-enterprise-operator
</code>
role is missing permission on replica sets.
</p>
<h3 id="private-registries-are-not-supported-on-openshift-311-red-38579">
Private registries are not supported on OpenShift 3.11 (RED-38579)
</h3>
<p>
OpenShift 3.11 does not support DockerHub private registries. This is a known OpenShift issue.
</p>
<h3 id="internal-dns-and-kubernetes-dns-may-have-conflicts-red-37462">
Internal DNS and Kubernetes DNS may have conflicts (RED-37462)
</h3>
<p>
DNS conflicts are possible between the cluster
<code>
mdns_server
</code>
and the K8s DNS. This only impacts DNS resolution from within cluster nodes for Kubernetes DNS names.
</p>
<h3 id="5410-negatively-impacts-546-red-37233">
5.4.10 negatively impacts 5.4.6 (RED-37233)
</h3>
<p>
Kubernetes-based 5.4.10 deployments seem to negatively impact existing 5.4.6 deployments that share a Kubernetes cluster.
</p>
<h3 id="node-cpu-usage-is-reported-instead-of-pod-cpu-usage-red-36884">
Node CPU usage is reported instead of pod CPU usage (RED-36884)
</h3>
<p>
In Kubernetes, the node CPU usage we report on is the usage of the Kubernetes worker node hosting the REC pod.
</p>
<h3 id="clusters-must-be-named-rec-in-olm-based-deployments-red-39825">
Clusters must be named "rec" in OLM-based deployments (RED-39825)
</h3>
<p>
In OLM-deployed operators, the deployment of the cluster will fail if the name is not "rec". When the operator is deployed via the OLM, the security context constraints (scc) are bound to a specific service account name (i.e., "rec"). The workaround is to name the cluster "rec".
</p>
<h3 id="rec-clusters-fail-to-start-on-kubernetes-clusters-with-unsynchronized-clocks-red-47254">
REC clusters fail to start on Kubernetes clusters with unsynchronized clocks (RED-47254)
</h3>
<p>
When REC clusters are deployed on Kubernetes clusters with unsynchronized clocks, the REC cluster does not start correctly. The fix is to use NTP to synchronize the underlying K8s nodes.
</p>
<h3 id="deleting-an-openshift-project-with-an-rec-deployed-may-hang-red-47192">
Deleting an OpenShift project with an REC deployed may hang (RED-47192)
</h3>
<p>
When a REC cluster is deployed in a project (namespace) and has REDB resources, the
REDB resources must be deleted first before the REC can be deleted. As such, until the
REDB resources are deleted, the project deletion will hang. The fix is to delete the
REDB resources first and the REC second. Afterwards, you may delete the project.
</p>
<h3 id="rec-extralabels-are-not-applied-to-pvcs-on-k8s-versions-115-or-older-red-51921">
REC extraLabels are not applied to PVCs on K8s versions 1.15 or older (RED-51921)
</h3>
<p>
In K8s 1.15 or older, the PVC labels come from the match selectors and not the
PVC templates. As such, these versions can not support PVC labels. If this feature
is required, the only fix is to upgrade the K8s cluster to a newer version.
</p>
<h3 id="hashicorp-vault-integration---no-support-for-gesher-red-55080">
Hashicorp Vault integration - no support for Gesher (RED-55080)
</h3>
<p>
There is no workaround at this time
</p>
<h3 id="rec-might-report-error-states-on-initial-startup-red-61707">
REC might report error states on initial startup (RED-61707)
</h3>
<p>
There is no workaround at this time except to ignore the errors.
</p>
<h3 id="pvc-size-issues-when-using-decimal-value-in-spec-red-62132">
PVC size issues when using decimal value in spec (RED-62132)
</h3>
<p>
The workaround for this issue is to make sure you use integer values for the PVC size.
</p>
<h2 id="compatibility-notes">
Compatibility Notes
</h2>
<p>
See
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
for the full list of supported distributions.
</p>
<h3 id="no-longer-supported">
No longer supported
</h3>
<ul>
<li>
kOps K8s versions 1.16 and 1.17 (previously deprecated) are no longer supported
</li>
<li>
AKS K8s version 1.18 (previously deprecated) is no longer supported
</li>
<li>
GKE K8s version 1.18 (previously deprecated) is no longer supported
</li>
<li>
VMWare TKGI version 1.7 (K8s 1.16) (previously deprecated) is no longer supported
</li>
<li>
VMWare TKGI version 1.8 (K8s 1.17) (previously deprecated) is no longer supported
</li>
</ul>
<h2 id="deprecation-notice">
Deprecation notice
</h2>
<ul>
<li>
Rancher version 2.4 support is deprecated
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/kubernetes/release-notes/k8s-6-2-8-2-2021-11/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/function-kill/.html | <section class="prose w-full py-12">
<h1 class="command-name">
FUNCTION KILL
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">FUNCTION KILL</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
7.0.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@scripting
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Kill a function that is currently executing.
</p>
<p>
The
<code>
FUNCTION KILL
</code>
command can be used only on functions that did not modify the dataset during their execution (since stopping a read-only function does not violate the scripting engine's guaranteed atomicity).
</p>
<p>
For more information please refer to
<a href="/docs/latest/develop/interact/programmability/functions-intro/">
Introduction to Redis Functions
</a>
.
</p>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#simple-strings">
Simple string reply
</a>
:
<code>
OK
</code>
.
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/function-kill/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/redis-data-integration/reference/jmespath-custom-functions/.html | <section class="prose w-full py-12 max-w-none">
<h1>
JMESPath custom functions
</h1>
<p class="text-lg -mt-5 mb-10">
JMESPath custom function reference
</p>
<table>
<thead>
<tr>
<th>
Function
</th>
<th>
Description
</th>
<th>
Example
</th>
<th>
Comments
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>
base64_decode
</code>
</td>
<td>
Decodes a base64(RFC 4648) encoded string
</td>
<td>
Input:
<code>
{"encoded": "SGVsbG8gV29ybGQh"}
</code>
<br/>
Expression:
<code>
base64_decode(encoded)
</code>
<br/>
Output:
<code>
Hello World!
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
capitalize
</code>
</td>
<td>
Capitalizes all the words in the string
</td>
<td>
Input:
<code>
{"name": "john doe"}
</code>
<br/>
Expression:
<code>
capitalize(name)
</code>
<br/>
Output:
<code>
John Doe
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
concat
</code>
</td>
<td>
Concatenates an array of variables or literals
</td>
<td>
Input:
<code>
{"fname": "john", "lname": "doe"}
</code>
<br/>
Expression:
<code>
concat([fname, ' ' ,lname])
</code>
<br/>
Output:
<code>
john doe
</code>
</td>
<td>
This is equivalent to the more verbose built-in expression:
<code>
' '.join([fname,lname])
</code>
</td>
</tr>
<tr>
<td>
<code>
filter_entries
</code>
</td>
<td>
Filters entries in a dictionary (object) using the given JMESPath predicate
</td>
<td>
Input:
<code>
{ "name": "John", "age": 30, "country": "US", "score": 15}
</code>
<br/>
Expression:
<code>
filter_entries(@, `key == 'name' || key == 'age'`)
</code>
<br/>
Output:
<code>
{"name": "John", "age": 30 }
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
from_entries
</code>
</td>
<td>
Converts an array of objects with
<code>
key
</code>
and
<code>
value
</code>
properties into a single object
</td>
<td>
Input:
<code>
[{"key": "name", "value": "John"}, {"key": "age", "value": 30}, {"key": "city", "value": null}]
</code>
<br/>
Expression:
<code>
from_entries(@)
</code>
<br/>
Output:
<code>
{"name": "John", "age": 30, "city": null}
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
hash
</code>
</td>
<td>
Calculates a hash using the
<code>
hash_name
</code>
hash function and returns its hexadecimal representation
</td>
<td>
Input:
<code>
{"some_str": "some_value"}
</code>
<br/>
Expression:
<code>
hash(some_str, &#96;sha1&#96;)
</code>
<br/>
Output:
<code>
8c818171573b03feeae08b0b4ffeb6999e3afc05
</code>
</td>
<td>
Supported algorithms: sha1 (default), sha256, md5, sha384, sha3_384, blake2b, sha512, sha3_224, sha224, sha3_256, sha3_512, blake2s
</td>
</tr>
<tr>
<td>
<code>
in
</code>
</td>
<td>
Checks if an element matches any value in a list of values
</td>
<td>
Input:
<code>
{"el": "b"}
</code>
<br/>
Expression:
<code>
in(el,
</code>
["a", "b", "c"]
<code>
)
</code>
<br/>
Output:
<code>
True
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
left
</code>
</td>
<td>
Returns a specified number of characters from the start of a given text string
</td>
<td>
Input:
<code>
{"greeting": "hello world!"}
</code>
<br/>
Expression:
<code>
left(greeting,
</code>
5
<code>
)
</code>
<br/>
Output:
<code>
hello
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
lower
</code>
</td>
<td>
Converts all uppercase characters in a string into lowercase characters
</td>
<td>
Input:
<code>
{"fname": "John"}
</code>
<br/>
Expression:
<code>
lower(fname)
</code>
<br/>
Output:
<code>
john
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
mid
</code>
</td>
<td>
Returns a specified number of characters from the middle of a given text string
</td>
<td>
Input:
<code>
{"greeting": "hello world!"}
</code>
<br/>
Expression:
<code>
mid(greeting,
</code>
4
<code>
,
</code>
3
<code>
)
</code>
<br/>
Output:
<code>
o w
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
json_parse
</code>
</td>
<td>
Returns parsed object from the given json string
</td>
<td>
Input:
<code>
{"data": '{"greeting": "hello world!"}'}
</code>
<br/>
Expression:
<code>
parse_json(data)
</code>
<br/>
Output:
<code>
{"greeting": "hello world!"}
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
regex_replace
</code>
</td>
<td>
Replaces a string that matches a regular expression
</td>
<td>
Input:
<code>
{"text": "Banana Bannnana"}
</code>
<br/>
Expression:
<code>
regex_replace(text, 'Ban\w+', 'Apple Apple')
</code>
<br/>
Output:
<code>
Apple Apple
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
replace
</code>
</td>
<td>
Replaces all the occurrences of a substring with a new one
</td>
<td>
Input:
<code>
{"sentence": "one four three four!"}
</code>
<br/>
Expression:
<code>
replace(sentence, 'four', 'two')
</code>
<br/>
Output:
<code>
one two three two!
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
right
</code>
</td>
<td>
Returns a specified number of characters from the end of a given text string
</td>
<td>
Input:
<code>
{"greeting": "hello world!"}
</code>
<br/>
Expression:
<code>
right(greeting,
</code>
6
<code>
)
</code>
<br/>
Output:
<code>
world!
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
split
</code>
</td>
<td>
Splits a string into a list of strings after breaking the given string by the specified delimiter (comma by default)
</td>
<td>
Input:
<code>
{"departments": "finance,hr,r&d"}
</code>
<br/>
Expression:
<code>
split(departments)
</code>
<br/>
Output:
<code>
['finance', 'hr', 'r&d']
</code>
</td>
<td>
Default delimiter is comma - a different delimiter can be passed to the function as the second argument, for example:
<code>
split(departments, ';')
</code>
</td>
</tr>
<tr>
<td>
<code>
time_delta_days
</code>
</td>
<td>
Returns the number of days between a given
<code>
dt
</code>
and now (positive) or the number of days that have passed from now (negative)
</td>
<td>
Input:
<code>
{"dt": '2021-10-06T18:56:16.701670+00:00'}
</code>
<br/>
Expression:
<code>
time_delta_days(dt)
</code>
<br/>
Output:
<code>
365
</code>
</td>
<td>
If
<code>
dt
</code>
is a string, ISO datetime (2011-11-04T00:05:23+04:00, for example) is assumed. If
<code>
dt
</code>
is a number, Unix timestamp (1320365123, for example) is assumed.
</td>
</tr>
<tr>
<td>
<code>
time_delta_seconds
</code>
</td>
<td>
Returns the number of seconds between a given
<code>
dt
</code>
and now (positive) or the number of seconds that have passed from now (negative)
</td>
<td>
Input:
<code>
{"dt": '2021-10-06T18:56:16.701670+00:00'}
</code>
<br/>
Expression:
<code>
time_delta_days(dt)
</code>
<br/>
Output:
<code>
31557600
</code>
</td>
<td>
If
<code>
dt
</code>
is a string, ISO datetime (2011-11-04T00:05:23+04:00, for example) is assumed. If
<code>
dt
</code>
is a number, Unix timestamp (1320365123, for example) is assumed.
</td>
</tr>
<tr>
<td>
<code>
to_entries
</code>
</td>
<td>
Converts a given object into an array of objects with
<code>
key
</code>
and
<code>
value
</code>
properties
</td>
<td>
Input:
<code>
{"name": "John", "age": 30, "city": null}
</code>
<br/>
Expression:
<code>
to_entries(@)
</code>
<br/>
Output:
<code>
[{"key": "name", "value": "John"}, {"key": "age", "value": 30}, {"key": "city", "value": null}]
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
upper
</code>
</td>
<td>
Converts all lowercase characters in a string into uppercase characters
</td>
<td>
Input:
<code>
{"fname": "john"}
</code>
<br/>
Expression:
<code>
upper(fname)
</code>
<br/>
Output:
<code>
JOHN
</code>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>
uuid
</code>
</td>
<td>
Generates a random UUID4 and returns it as a string in standard format
</td>
<td>
Input: None
<br/>
Expression:
<code>
uuid()
</code>
<br/>
Output:
<code>
3264b35c-ff5d-44a8-8bc7-9be409dac2b7
</code>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/reference/jmespath-custom-functions/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/development/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Development
</h1>
<p class="text-lg -mt-5 mb-10">
How to develop for triggers and functions
</p>
<div class="banner-article rounded-md">
<p>
The Redis Stack triggers and functions feature preview has ended and it will not be promoted to GA.
</p>
</div>
<p>
To aid in the development of new libraries of triggers and functions, you can use the type declaration files for the
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/concepts/javascript_api/">
triggers and functions API
</a>
, which allows your preferred development environment to provide autocompletion and type checking. You can install this information using the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">npm install https://gitpkg.now.sh/RedisGears/RedisGears/js_api --save-dev
</span></span></code></pre>
</div>
<p>
Or you can manually add it as a devDependency to your
<code>
package.json
</code>
file:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="s2">"devDependencies"</span><span class="err">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"@redis/gears-api"</span><span class="p">:</span> <span class="s2">"https://gitpkg.now.sh/RedisGears/RedisGears/js_api"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h2 id="example-project-setup">
Example project setup
</h2>
<p>
Create an empty directory for your new triggers and functions project,
<code>
my_first_project
</code>
. Navigate to the folder and run the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ npm init -y -f
</span></span><span class="line"><span class="cl">npm WARN using --force Recommended protections disabled.
</span></span><span class="line"><span class="cl">Wrote to /home/work/my_first_project/package.json:
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span>: <span class="s2">"my_first_project"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"version"</span>: <span class="s2">"1.0.0"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"description"</span>: <span class="s2">""</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"main"</span>: <span class="s2">"index.js"</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"scripts"</span>: <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"test"</span>: <span class="s2">"echo \"Error: no test specified\" && exit 1"</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"keywords"</span>: <span class="o">[]</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"author"</span>: <span class="s2">""</span>,
</span></span><span class="line"><span class="cl"> <span class="s2">"license"</span>: <span class="s2">"ISC"</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
<p>
Update the
<code>
package.json
</code>
to add the gears API to the
<code>
devDependencies
</code>
object.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-js" data-lang="js"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"name"</span><span class="o">:</span> <span class="s2">"my_first_project"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"version"</span><span class="o">:</span> <span class="s2">"1.0.0"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"description"</span><span class="o">:</span> <span class="s2">""</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"main"</span><span class="o">:</span> <span class="s2">"index.js"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"scripts"</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"test"</span><span class="o">:</span> <span class="s2">"echo \"Error: no test specified\" && exit 1"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"devDependencies"</span><span class="o">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"@redis/gears-api"</span><span class="o">:</span> <span class="s2">"https://gitpkg.now.sh/RedisGears/RedisGears/js_api"</span>
</span></span><span class="line"><span class="cl"> <span class="p">},</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"keywords"</span><span class="o">:</span> <span class="p">[],</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"author"</span><span class="o">:</span> <span class="s2">""</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"license"</span><span class="o">:</span> <span class="s2">"ISC"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
Install the dependencies using
<code>
npm install
</code>
.
</p>
<p>
Create a new file,
<code>
index.js
</code>
and import the gears-api module. While this step is not strictly necessary, doing so will enable code intelligent code completion when adding the
<code>
registerFunction
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-JavaScript" data-lang="JavaScript"><span class="line"><span class="cl"><span class="err">#</span><span class="o">!</span><span class="nx">js</span> <span class="nx">name</span><span class="o">=</span><span class="nx">lib</span> <span class="nx">api_version</span><span class="o">=</span><span class="mf">1.0</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">redis</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'@redis/gears-api'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerFunction</span><span class="p">(</span><span class="s2">"test"</span><span class="p">,</span> <span class="p">()=>{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="s2">"test"</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">});</span>
</span></span></code></pre>
</div>
<p>
To automate the deployment, update the
<code>
scripts
</code>
section in
<code>
package.json
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="s2">"scripts"</span><span class="err">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"deploy"</span><span class="p">:</span> <span class="s2">"gears-api index.js"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
Now you can deploy your code to Redis Stack using the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">> npm run deploy -- -r redis://localhost:6379
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">> deploy
</span></span><span class="line"><span class="cl">> gears-api index.js
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Deployed! :<span class="o">)</span>
</span></span></code></pre>
</div>
<p>
The provided URL should follow the following format:
</p>
<p>
<code>
<redis[s]://[[username][:password]@][host][:port][/db-number]>
</code>
</p>
<p>
You can now run your Redis Stack function:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">127.0.0.1:6379> TFCALL lib.test <span class="m">0</span>
</span></span><span class="line"><span class="cl"><span class="s2">"test"</span>
</span></span></code></pre>
</div>
<h2 id="example-function-using-a-third-party-npm-package">
Example function using a third-party
<code>
npm
</code>
package
</h2>
<p>
If you want to use a third-party
<code>
npm
</code>
package in your Redis Stack function, the overall process is nearly the same as already discussed, with just a couple of differences.
</p>
<p>
First, you'll need to install your package using
<code>
npm install
</code>
. For this example, the
<code>
pi
</code>
symbol from the
<code>
math.js
</code>
library will be used in a simple function that calculates the area of a circle.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">npm install mathjs
</span></span></code></pre>
</div>
<p>
Note: your
<code>
package.json
</code>
file will also be updated with the new dependency. For example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="s2">"dependencies"</span><span class="err">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"mathjs"</span><span class="p">:</span> <span class="s2">"^12.0.0"</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<p>
Next, you'll import the required symbol(s) into your function.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-javascript" data-lang="javascript"><span class="line"><span class="cl"><span class="err">#</span><span class="o">!</span><span class="nx">js</span> <span class="nx">api_version</span><span class="o">=</span><span class="mf">1.0</span> <span class="nx">name</span><span class="o">=</span><span class="nx">lib</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">redis</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'@redis/gears-api'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="kr">import</span> <span class="p">{</span> <span class="nx">pi</span> <span class="p">}</span> <span class="nx">from</span> <span class="s1">'mathjs'</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">function</span> <span class="nx">calculateCircleArea</span><span class="p">(</span><span class="nx">client</span><span class="p">,</span> <span class="nx">radius</span><span class="p">)</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="k">return</span> <span class="nx">pi</span> <span class="o">*</span> <span class="nx">radius</span> <span class="o">*</span> <span class="nx">radius</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nx">redis</span><span class="p">.</span><span class="nx">registerFunction</span><span class="p">(</span><span class="s1">'calculateArea'</span><span class="p">,</span> <span class="nx">calculateCircleArea</span><span class="p">);</span>
</span></span></code></pre>
</div>
<p>
Load and run your new function as described in the previous section.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/oss_and_stack/stack-with-enterprise/deprecated-features/triggers-and-functions/development/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/upgrade-paths/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Supported upgrade paths for Redis Software
</h1>
<p class="text-lg -mt-5 mb-10">
Supported paths to upgrade a Redis Software cluster.
</p>
<h2 id="supported-upgrade-paths">
Supported upgrade paths
</h2>
<p>
<span title="Check mark icon">
β
</span>
Supported β You can upgrade directly from the current Redis Software cluster version.
</p>
<p>
<span title="X icon">
β
</span>
Not supported β You cannot upgrade directly from the current Redis Software cluster version. You must first upgrade to a supported intermediate version.
</p>
<table>
<thead>
<tr>
<th style="text-align:center">
Current Redis Software cluster version
</th>
<th style="text-align:center">
Upgrade to Redis Software 6.2.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 6.4.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.2.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.4.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.8.x
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">
6.0.x
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.2.4
<br/>
6.2.8
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.2.10
<br/>
6.2.12
<br/>
6.2.18
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.4.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
7.2.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
7.4.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
-
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
</tbody>
</table>
<p>
For detailed upgrade instructions, see
<a href="/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-cluster/">
Upgrade a Redis Enterprise Software cluster
</a>
.
</p>
<p>
See the
<a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/">
Redis Enterprise Software product lifecycle
</a>
for more information about release numbers and the end-of-life schedule.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Redis Enterprise for Kubernetes has its own support lifecycle, which accounts for the Kubernetes distribution lifecycle. For details, see
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
.
</div>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/upgrade-paths/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/grouphyperloglog.html | <section class="prose w-full py-12">
<h1>
Commands
</h1>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/bootstrap/node_identity/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Node identity object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the node_identity object used with Redis Enterprise Software REST API calls.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
bigstore_driver
</td>
<td>
'rocksdb'
</td>
<td>
Bigstore driver name or none (deprecated)
</td>
</tr>
<tr>
<td>
bigstore_enabled
</td>
<td>
boolean
</td>
<td>
Bigstore enabled or disabled
</td>
</tr>
<tr>
<td>
identity
</td>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/objects/bootstrap/identity/">
identity
</a>
object
</td>
<td>
Node identity
</td>
</tr>
<tr>
<td>
limits
</td>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/objects/bootstrap/limits/">
limits
</a>
object
</td>
<td>
Node limits
</td>
</tr>
<tr>
<td>
paths
</td>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/objects/bootstrap/paths/">
paths
</a>
object
</td>
<td>
Storage paths object
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/bootstrap/node_identity/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/redisinsight/install/install-on-k8s/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Install on Kubernetes
</h1>
<p class="text-lg -mt-5 mb-10">
How to install Redis Insight on Kubernetes
</p>
<p>
This tutorial shows how to install Redis Insight on
<a href="https://kubernetes.io/">
Kubernetes
</a>
(K8s).
This is an easy way to use Redis Insight with a
<a href="/docs/latest/operate/kubernetes/">
Redis Enterprise K8s deployment
</a>
.
</p>
<h2 id="create-the-redis-insight-deployment-and-service">
Create the Redis Insight deployment and service
</h2>
<p>
Below is an annotated YAML file that will create a Redis Insight
deployment and a service in a K8s cluster.
</p>
<ol>
<li>
Create a new file named
<code>
redisinsight.yaml
</code>
with the content below.
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># Redis Insight service with name 'redisinsight-service'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Service</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight-service </span><span class="w"> </span><span class="c"># name should not be 'redisinsight'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># since the service creates</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># environment variables that</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># conflicts with redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># application's environment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># variables `RI_APP_HOST` and</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># `RI_APP_PORT`</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l">LoadBalancer</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="m">80</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">targetPort</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nn">---</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c"># Redis Insight deployment with name 'redisinsight'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">apps/v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Deployment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment label</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicas</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="c">#a single replica pod</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">matchLabels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#which pods is the deployment managing, as defined by the pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">template</span><span class="p">:</span><span class="w"> </span><span class="c">#pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#label for pod/s</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">containers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Container name (DNS_LABEL, unique)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">redis/redisinsight:latest</span><span class="w"> </span><span class="c">#repo/image</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">imagePullPolicy</span><span class="p">:</span><span class="w"> </span><span class="l">IfNotPresent</span><span class="w"> </span><span class="c">#Installs the latest Redis Insight version</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumeMounts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Pod volumes to mount into the container's filesystem. Cannot be updated.</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mountPath</span><span class="p">:</span><span class="w"> </span><span class="l">/data</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">containerPort</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w"> </span><span class="c">#exposed container port and protocol</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">protocol</span><span class="p">:</span><span class="w"> </span><span class="l">TCP</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">emptyDir</span><span class="p">:</span><span class="w"> </span>{}<span class="w"> </span><span class="c"># node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydir</span><span class="w">
</span></span></span></code></pre>
</div>
<ol start="2">
<li>
Create the Redis Insight deployment and service:
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f redisinsight.yaml
</span></span></code></pre>
</div>
<ol start="3">
<li>
Once the deployment and service are successfully applied and complete, access Redis Insight. This can be accomplished by using the
<code>
<external-ip>
</code>
of the service we created to reach Redis Insight.
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ kubectl get svc redisinsight-service
</span></span><span class="line"><span class="cl">NAME CLUSTER-IP EXTERNAL-IP PORT<span class="o">(</span>S<span class="o">)</span> AGE
</span></span><span class="line"><span class="cl">redisinsight-service <cluster-ip> <external-ip> 80:32143/TCP 1m
</span></span></code></pre>
</div>
<ol start="4">
<li>
If you are using minikube, run
<code>
minikube list
</code>
to list the service and access Redis Insight at
<code>
http://<minikube-ip>:<minikube-service-port>
</code>
.
</li>
</ol>
<pre tabindex="0"><code>$ minikube list
|-------------|----------------------|--------------|---------------------------------------------|
| NAMESPACE | NAME | TARGET PORT | URL |
|-------------|----------------------|--------------|---------------------------------------------|
| default | kubernetes | No node port | |
| default | redisinsight-service | 80 | http://<minikube-ip>:<minikubeservice-port> |
| kube-system | kube-dns | No node port | |
|-------------|----------------------|--------------|---------------------------------------------|
</code></pre>
<h2 id="create-the-redis-insight-deployment-with-persistant-storage">
Create the Redis Insight deployment with persistant storage
</h2>
<p>
Below is an annotated YAML file that will create a Redis Insight
deployment in a K8s cluster. It will assign a peristent volume created from a volume claim template.
Write access to the container is configured in an init container. When using deployments
with persistent writeable volumes, it's best to set the strategy to
<code>
Recreate
</code>
. Otherwise you may find yourself
with two pods trying to use the same volume.
</p>
<ol>
<li>
Create a new file
<code>
redisinsight.yaml
</code>
with the content below.
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># Redis Insight service with name 'redisinsight-service'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Service</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight-service </span><span class="w"> </span><span class="c"># name should not be 'redisinsight'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># since the service creates</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># environment variables that</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># conflicts with redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># application's environment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># variables `RI_APP_HOST` and</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># `RI_APP_PORT`</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l">LoadBalancer</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="m">80</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">targetPort</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nn">---</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">PersistentVolumeClaim</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight-pv-claim</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">accessModes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">ReadWriteOnce</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">resources</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">requests</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">storage</span><span class="p">:</span><span class="w"> </span><span class="l">2Gi</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">storageClassName</span><span class="p">:</span><span class="w"> </span><span class="l">default</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nn">---</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c"># Redis Insight deployment with name 'redisinsight'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">apps/v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Deployment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment label</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicas</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="c">#a single replica pod</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">strategy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l">Recreate</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">matchLabels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#which pods is the deployment managing, as defined by the pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">template</span><span class="p">:</span><span class="w"> </span><span class="c">#pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#label for pod/s</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">persistentVolumeClaim</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">claimName</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight-pv-claim</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">initContainers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">init</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">busybox</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">command</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="l">/bin/sh</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="s1">'-c'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="p">|</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd"> chown -R 1000 /data</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">resources</span><span class="p">:</span><span class="w"> </span>{}<span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumeMounts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mountPath</span><span class="p">:</span><span class="w"> </span><span class="l">/data</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">terminationMessagePath</span><span class="p">:</span><span class="w"> </span><span class="l">/dev/termination-log</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">terminationMessagePolicy</span><span class="p">:</span><span class="w"> </span><span class="l">File</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">containers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Container name (DNS_LABEL, unique)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">redis/redisinsight:latest</span><span class="w"> </span><span class="c">#repo/image</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">imagePullPolicy</span><span class="p">:</span><span class="w"> </span><span class="l">IfNotPresent</span><span class="w"> </span><span class="c">#Always pull image</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumeMounts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Pod volumes to mount into the container's filesystem. Cannot be updated.</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mountPath</span><span class="p">:</span><span class="w"> </span><span class="l">/data</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">containerPort</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w"> </span><span class="c">#exposed container port and protocol</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">protocol</span><span class="p">:</span><span class="w"> </span><span class="l">TCP</span><span class="w">
</span></span></span></code></pre>
</div>
<ol start="2">
<li>
Create the Redis Insight deployment and service.
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f redisinsight.yaml
</span></span></code></pre>
</div>
<h2 id="create-the-redis-insight-deployment-without-a-service">
Create the Redis Insight deployment without a service.
</h2>
<p>
Below is an annotated YAML file that will create a Redis Insight
deployment in a K8s cluster.
</p>
<ol>
<li>
Create a new file redisinsight.yaml with the content below
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">apiVersion</span><span class="p">:</span><span class="w"> </span><span class="l">apps/v1</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">kind</span><span class="p">:</span><span class="w"> </span><span class="l">Deployment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment name</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#deployment label</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">replicas</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="c">#a single replica pod</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">selector</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">matchLabels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#which pods is the deployment managing, as defined by the pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">template</span><span class="p">:</span><span class="w"> </span><span class="c">#pod template</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">metadata</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">app</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#label for pod/s</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">spec</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">containers</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Container name (DNS_LABEL, unique)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">redis/redisinsight:latest</span><span class="w"> </span><span class="c">#repo/image</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">imagePullPolicy</span><span class="p">:</span><span class="w"> </span><span class="l">IfNotPresent</span><span class="w"> </span><span class="c">#Always pull image</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">env</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># If there's a service named 'redisinsight' that exposes the</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># deployment, we manually set `RI_APP_HOST` and</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># `RI_APP_PORT` to override the service environment</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># variables.</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">RI_APP_HOST</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">value</span><span class="p">:</span><span class="w"> </span><span class="s2">"0.0.0.0"</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">RI_APP_PORT</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">value</span><span class="p">:</span><span class="w"> </span><span class="s2">"5540"</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumeMounts</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w"> </span><span class="c">#Pod volumes to mount into the container's filesystem. Cannot be updated.</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">mountPath</span><span class="p">:</span><span class="w"> </span><span class="l">/data</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">ports</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">containerPort</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w"> </span><span class="c">#exposed container port and protocol</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">protocol</span><span class="p">:</span><span class="w"> </span><span class="l">TCP</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">livenessProbe</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">httpGet</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">path </span><span class="p">:</span><span class="w"> </span><span class="l">/healthcheck/</span><span class="w"> </span><span class="c"># exposed RI endpoint for healthcheck</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">port</span><span class="p">:</span><span class="w"> </span><span class="m">5540</span><span class="w"> </span><span class="c"># exposed container port</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">initialDelaySeconds</span><span class="p">:</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="c"># number of seconds to wait after the container starts to perform liveness probe</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">periodSeconds</span><span class="p">:</span><span class="w"> </span><span class="m">5</span><span class="w"> </span><span class="c"># period in seconds after which liveness probe is performed</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">failureThreshold</span><span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w"> </span><span class="c"># number of liveness probe failures after which container restarts</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">redisinsight</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">emptyDir</span><span class="p">:</span><span class="w"> </span>{}<span class="w"> </span><span class="c"># node-ephemeral volume https://kubernetes.io/docs/concepts/storage/volumes/#emptydir</span><span class="w">
</span></span></span></code></pre>
</div>
<ol start="2">
<li>
Create the Redis Insight deployment
</li>
</ol>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl apply -f redisinsight.yaml
</span></span></code></pre>
</div>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
If the deployment will be exposed by a service whose name is 'redisinsight', set
<code>
RI_APP_HOST
</code>
and
<code>
RI_APP_PORT
</code>
environment variables to override the environment variables created by the service.
</div>
</div>
<h2 id="run-redis-insight">
Run Redis Insight
</h2>
<p>
Once the deployment has been successfully applied and the deployment is complete, access Redis Insight. This can be accomplished by exposing the deployment as a K8s Service or by using port forwarding, as in the example below:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">kubectl port-forward deployment/redisinsight <span class="m">5540</span>
</span></span></code></pre>
</div>
<p>
Open your browser and point to
<a href="http://localhost:5540">
http://localhost:5540
</a>
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/redisinsight/install/install-on-k8s/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/list/.html | <section class="prose w-full py-12 max-w-none">
<h1>
crdb-cli crdb list
</h1>
<p class="text-lg -mt-5 mb-10">
Shows a list of all Active-Active databases.
</p>
<p>
Shows a list of all Active-Active databases.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli crdb list
</span></span></code></pre>
</div>
<h3 id="parameters">
Parameters
</h3>
<p>
None
</p>
<h3 id="returns">
Returns
</h3>
<p>
Returns a list of all Active-Active databases that the cluster participates in. Each database is represented with a unique GUID, the name of the database, an instance ID, and the FQDN of the cluster that hosts the instance.
</p>
<h3 id="example">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli crdb list
</span></span><span class="line"><span class="cl">CRDB-GUID NAME REPL-ID CLUSTER-FQDN
</span></span><span class="line"><span class="cl">d84f6fe4-5bb7-49d2-a188-8900e09c6f66 database1 <span class="m">1</span> cluster1.redis.local
</span></span><span class="line"><span class="cl">d84f6fe4-5bb7-49d2-a188-8900e09c6f66 database1 <span class="m">2</span> cluster2.redis.local
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/crdb-cli/crdb/list/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-cluster/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Upgrade a Redis Enterprise Software cluster
</h1>
<p class="text-lg -mt-5 mb-10">
Upgrade a Redis Enterprise Software cluster.
</p>
<h2 id="supported-upgrade-paths">
Supported upgrade paths
</h2>
<p>
<span title="Check mark icon">
β
</span>
Supported β You can upgrade directly from the current Redis Software cluster version.
</p>
<p>
<span title="X icon">
β
</span>
Not supported β You cannot upgrade directly from the current Redis Software cluster version. You must first upgrade to a supported intermediate version.
</p>
<table>
<thead>
<tr>
<th style="text-align:center">
Current Redis Software cluster version
</th>
<th style="text-align:center">
Upgrade to Redis Software 6.2.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 6.4.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.2.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.4.x
</th>
<th style="text-align:center">
Upgrade to Redis Software 7.8.x
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">
6.0.x
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.2.4
<br/>
6.2.8
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Not supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.2.10
<br/>
6.2.12
<br/>
6.2.18
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
6.4.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
7.2.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
<tr>
<td style="text-align:center">
7.4.x
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
β
</td>
<td style="text-align:center">
-
</td>
<td style="text-align:center">
<span title="Supported">
β
</span>
</td>
</tr>
</tbody>
</table>
<p>
See the
<a href="/docs/latest/operate/rs/installing-upgrading/product-lifecycle/">
Redis Enterprise Software product lifecycle
</a>
for more information about release numbers and the end-of-life schedule.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
Redis Enterprise for Kubernetes has its own support lifecycle, which accounts for the Kubernetes distribution lifecycle. For details, see
<a href="/docs/latest/operate/kubernetes/reference/supported_k8s_distributions/">
Supported Kubernetes distributions
</a>
.
</div>
</div>
<h2 id="upgrade-prerequisites">
Upgrade prerequisites
</h2>
<p>
Before upgrading a cluster:
</p>
<ul>
<li>
<p>
Verify access to
<a href="/docs/latest/operate/rs/references/cli-utilities/rlcheck/">
rlcheck
</a>
and
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/#use-the-rladmin-shell">
rladmin
</a>
commands
</p>
</li>
<li>
<p>
Verify that you meet the upgrade path requirements for your desired cluster version and review the relevant
<a href="/docs/latest/operate/rs/release-notes/">
release notes
</a>
for any preparation instructions.
</p>
</li>
<li>
<p>
Avoid changing the database configuration or performing other cluster management operations during the upgrade process, as this might cause unexpected results.
</p>
</li>
<li>
<p>
Upgrade the cluster's primary (master) node first. To identify the primary node, use one of the following methods:
</p>
<ul>
<li>
<p>
<strong>
Nodes
</strong>
screen in the new Cluster Manager UI (only available for Redis Enterprise versions 7.2 and later)
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/status/#status-nodes">
<code>
rladmin status nodes
</code>
</a>
command
</p>
</li>
<li>
<p>
<a href="/docs/latest/operate/rs/references/rest-api/requests/nodes/status/#get-all-nodes-status">
<code>
GET /nodes/status
</code>
</a>
REST API request
</p>
</li>
</ul>
</li>
</ul>
<h2 id="upgrade-cluster">
Upgrade cluster
</h2>
<p>
Starting with the primary (master) node, follow these steps for every node in the cluster. To ensure cluster availability, upgrade each node separately.
</p>
<ol>
<li>
<p>
Verify node operation with the following commands:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">$ rlcheck
</span></span><span class="line"><span class="cl">$ rladmin status extra all
</span></span></code></pre>
</div>
</li>
<li>
<p>
Download the Redis Enterprise Software installation package to the machine running the node from the Download Center on
<a href="https://cloud.redis.io">
https://cloud.redis.io
</a>
.
</p>
</li>
<li>
<p>
Extract the installation package:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">tar vxf <tarfile name>
</span></span></code></pre>
</div>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
You cannot change the installation path or the user during the upgrade.
</div>
</div>
</li>
<li>
<p>
Run the install command. See
<a href="/docs/latest/operate/rs/installing-upgrading/install/install-script/">
installation script options
</a>
for a list of command-line options you can add to the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">sudo ./install.sh
</span></span></code></pre>
</div>
<p>
The installation script automatically recognizes the upgrade and responds accordingly.
</p>
<p>
The upgrade replaces all node processes, which might briefly interrupt any active connections.
</p>
</li>
<li>
<p>
Verify the node was upgraded to the new version and is still operational:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">$ rlcheck
</span></span><span class="line"><span class="cl">$ rladmin status extra all
</span></span></code></pre>
</div>
</li>
<li>
<p>
Visit the Cluster Manager UI.
</p>
<p>
If the Cluster Manager UI was open in a web browser during the upgrade, refresh the browser to reload the console.
</p>
</li>
</ol>
<p>
After all nodes are upgraded, the cluster is fully upgraded. Certain features introduced in the new version of Redis Enterprise Software only become available after upgrading the entire cluster.
</p>
<p>
After upgrading from version 6.0.x to 6.2.x, restart
<code>
cnm_exec
</code>
on each cluster node to enable more advanced state machine handling capabilities:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">supervisorctl restart cnm_exec
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/installing-upgrading/upgrading/upgrade-cluster/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-delete/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di delete
</h1>
<p class="text-lg -mt-5 mb-10">
Deletes Write-behind database permanently
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di delete [OPTIONS]
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
loglevel
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--loglevel -log-level
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
cluster_host
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-host
</code>
</li>
</ul>
<p>
Host/IP of Redis Enterprise Cluster (service name in case of k8s)
</p>
</li>
<li>
<p>
<code>
cluster_api_port
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: <IntRange 1000<=x<=65535>
</li>
<li>
Default:
<code>
9443
</code>
</li>
<li>
Usage:
<code>
--cluster-api-port
</code>
</li>
</ul>
<p>
API Port of Redis Enterprise Cluster
</p>
</li>
<li>
<p>
<code>
cluster_user
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-user
</code>
</li>
</ul>
<p>
Redis Enterprise Cluster username with either DB Member, Cluster Member or Cluster Admin roles
</p>
</li>
<li>
<p>
<code>
cluster_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--cluster-password
</code>
</li>
</ul>
<p>
Redis Enterprise Cluster Password
</p>
</li>
<li>
<p>
<code>
rdi_host
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-host
</code>
</li>
</ul>
<p>
Host/IP of Write-behind Database
</p>
</li>
<li>
<p>
<code>
rdi_port
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: <IntRange 1000<=x<=65535>
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-port
</code>
</li>
</ul>
<p>
Port of Write-behind Database
</p>
</li>
<li>
<p>
<code>
rdi_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-password
</code>
</li>
</ul>
<p>
Write-behind Database Password
</p>
</li>
<li>
<p>
<code>
rdi_key
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-key
</code>
</li>
</ul>
<p>
Private key file to authenticate with
</p>
</li>
<li>
<p>
<code>
rdi_cert
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-cert
</code>
</li>
</ul>
<p>
Client certificate file to authenticate with
</p>
</li>
<li>
<p>
<code>
rdi_cacert
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-cacert
</code>
</li>
</ul>
<p>
CA certificate file to verify with
</p>
</li>
<li>
<p>
<code>
rdi_key_password
</code>
:
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
--rdi-key-password
</code>
</li>
</ul>
<p>
Password for unlocking an encrypted private key
</p>
</li>
<li>
<p>
<code>
force
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--force -f
</code>
</li>
</ul>
<p>
Force operation. skips verification prompts
</p>
</li>
<li>
<p>
<code>
help
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--help
</code>
</li>
</ul>
<p>
Show this message and exit.
</p>
</li>
</ul>
<h2 id="cli-help">
CLI help
</h2>
<pre tabindex="0"><code>Usage: redis-di delete [OPTIONS]
Deletes Write-behind database permanently
Options:
-log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
--cluster-host TEXT Host/IP of Redis Enterprise Cluster (service
name in case of k8s) [required]
--cluster-api-port INTEGER RANGE
API Port of Redis Enterprise Cluster
[default: 9443; 1000<=x<=65535; required]
--cluster-user TEXT Redis Enterprise Cluster username with
either DB Member, Cluster Member or Cluster
Admin roles [required]
--cluster-password TEXT Redis Enterprise Cluster Password
--rdi-host TEXT Host/IP of Write-behind Database [required]
--rdi-port INTEGER RANGE Port of Write-behind Database [1000<=x<=65535;
required]
--rdi-password TEXT Write-behind Database Password
--rdi-key TEXT Private key file to authenticate with
--rdi-cert TEXT Client certificate file to authenticate with
--rdi-cacert TEXT CA certificate file to verify with
--rdi-key-password TEXT Password for unlocking an encrypted private
key
-f, --force Force operation. skips verification prompts
--help Show this message and exit.
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-delete/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/cloud-integrations/aws-cloud-accounts/iam-resources/cloudformation/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Create IAM resources using CloudFormation
</h1>
<div class="banner-article rounded-md">
<p>
Self-managed AWS accounts are deprecated, so this article has been archived.
</p>
</div>
<p>
The following link uses
<a href="https://aws.amazon.com/cloudformation/">
AWS CloudFormation
</a>
to create a stack using the AWS console:
</p>
<a href="https://console.aws.amazon.com/cloudformation/home?#/stacks/new?stackName=RedisCloud&templateURL=https://s3.amazonaws.com/iam-resource-automation-do-not-delete/RedisCloud.yaml">
<img alt="Launch RedisCloud template" src="https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png"/>
</a>
<p>
You can then use the
<code>
Outputs
</code>
tab to find the data needed to complete the creation of a Cloud Account. For the
<code>
accessSecretKey
</code>
(i.e. user's access key) and
<code>
consolePassword
</code>
(user's console password) you'll have to follow the links to the AWS Secrets Manager service, and use that to find the secret values. These values, being secrets, aren't displayed directly by CloudFormation.
</p>
<p>
You can use the AWS command-line interface (CLI) if you prefer:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">AWS_PROFILE</span><span class="o">=</span>YOUR_PROFILE_HERE
</span></span><span class="line"><span class="cl">aws cloudformation create-stack --stack-name RedisCloud --template-url <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>https://s3.amazonaws.com/iam-resource-automation-do-not-delete/RedisCloud.yaml <span class="se">\
</span></span></span><span class="line"><span class="cl"><span class="se"></span>--capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_NAMED_IAM CAPABILITY_IAM
</span></span></code></pre>
</div>
<p>
Update the values of
<code>
AWS_PROFILE
</code>
with your profile credentials.
</p>
<p>
Additional options are described in the
<a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html">
AWS CLI docs
</a>
.
</p>
<p>
You can track the status of the cloud formation with the following command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-console" data-lang="console"><span class="line"><span class="cl"><span class="go">aws cloudformation describe-stacks --stack-name RedisCloud
</span></span></span></code></pre>
</div>
<p>
The data needed to complete the creation of a Cloud Account is shown as
<code>
Output Key
</code>
and
<code>
Output Value
</code>
pairs.
</p>
<p>
For the two secrets (
<code>
accessSecretKey
</code>
and
<code>
consolePassword
</code>
) you'll need to use the AWS secretmanager CLI - the value you'll need has a key of
<code>
SecretString
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-console" data-lang="console"><span class="line"><span class="cl"><span class="go">aws secretsmanager get-secret-value --secret-id=/redislabsuser/secret_access_key
</span></span></span></code></pre>
</div>
<p>
We recommend using yaml output for the
<code>
consolePassword
</code>
, as it makes decoding the required value easier.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-console" data-lang="console"><span class="line"><span class="cl"><span class="go">aws secretsmanager get-secret-value --secret-id=/redislabsuser/password --output yaml
</span></span></span></code></pre>
</div>
<p>
The
<code>
consolePassword
</code>
is a JSON object containing a single member whose key is
<code>
password
</code>
and whose value is the password. This can be a bit complex to parse out. Here's an example output:
</p>
<pre tabindex="0"><code>user@example-computer ~ % aws secretsmanager get-secret-value
--secret-id=/redislabsuser/password
--output yaml
ARN: arn:aws:secretsmanager:middle-earth-1:913769183952γοΈ/redislabsuser/password-qaEMYs
CreatedDate: '2021-06-16T06:27:53.402000-06:00'
Name: /redislabsuser/password
SecretString: '{"password":"S3cr3tP@$$w0rd"}'
VersionId: 00000000-0000-0000-0000-000000000000
VersionStages:
- AWSCURRENT
</code></pre>
<p>
The JSON object is the value (less the single quotes) of the
<code>
SecretString
</code>
key. i.e. it is
<nobr>
<code>
{"password":"S3cr3tP@$$w0rd"}
</code>
</nobr>
.
</p>
<p>
The password is the value associated with that key (less the double quotes):
<code>
S3cr3tP@$$w0rd
</code>
.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/cloud-integrations/aws-cloud-accounts/iam-resources/cloudformation/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/data-denormalization/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Data denormalization
</h1>
<p class="text-lg -mt-5 mb-10">
Learn about denormalization strategies
</p>
<p>
The data in the source database is often
<a href="https://en.wikipedia.org/wiki/Database_normalization">
<em>
normalized
</em>
</a>
.
This means that columns can't have composite values (such as arrays) and relationships between entities
are expressed as mappings of primary keys to foreign keys between different tables.
Normalized data models reduce redundancy and improve data integrity for write queries but this comes
at the expense of speed.
A Redis cache, on the other hand, is focused on making
<em>
read
</em>
queries fast, so RDI provides data
<em>
denormalization
</em>
to help with this.
</p>
<h2 id="nest-strategy">
Nest strategy
</h2>
<p>
<em>
Nesting
</em>
is the strategy RDI uses to denormalize many-to-one relationships in the source database.
It does this by representing the
parent object (the "one") as a JSON document with the children (the "many") nested inside a JSON map
attribute in the parent. The diagram belows shows a nesting with the child objects in a map
called
<code>
InvoiceLineItems
</code>
:
</p>
<a href="/docs/latest/images/rdi/nest-flow.png" sdata-lightbox="/images/rdi/nest-flow.png">
<img src="/docs/latest/images/rdi/nest-flow.png"/>
</a>
<p>
You configure normalization with a
<code>
nest
</code>
block in the child entities' RDI job, as shown in this example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">source</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">server_name</span><span class="p">:</span><span class="w"> </span><span class="l">chinook</span><span class="w"> </span><span class="c"># Optional. Use the value of `debezium.source.topic.prefix` property in Debezium's `application.properties`</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">schema</span><span class="p">:</span><span class="w"> </span><span class="l">public</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">table</span><span class="p">:</span><span class="w"> </span><span class="l">InvoiceLine</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">output</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span>- <span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">redis.write</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">with</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">nest</span><span class="p">:</span><span class="w"> </span><span class="c"># cannot co-exist with other parameters such as 'key'</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">parent</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># server_name: chinook</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="c"># schema: public</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">table</span><span class="p">:</span><span class="w"> </span><span class="l">Invoice</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">nesting_key</span><span class="p">:</span><span class="w"> </span><span class="l">InvoiceLineId</span><span class="w"> </span><span class="c"># cannot be composite</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">parent_key</span><span class="p">:</span><span class="w"> </span><span class="l">InvoiceId</span><span class="w"> </span><span class="c"># cannot be composite</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">path</span><span class="p">:</span><span class="w"> </span><span class="l">$.InvoiceLineItems</span><span class="w"> </span><span class="c"># path must start from document root ($)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">structure</span><span class="p">:</span><span class="w"> </span><span class="l">map</span><span class="w"> </span><span class="c"># only map supported for now</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">on_update</span><span class="p">:</span><span class="w"> </span><span class="l">merge</span><span class="w"> </span><span class="c"># only merge supported for now</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"> </span><span class="nt">data_type</span><span class="p">:</span><span class="w"> </span><span class="l">json</span><span class="w"> </span><span class="c"># only json supported for now</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
The job has a
<code>
with
</code>
section under
<code>
output
</code>
that includes the
<code>
nest
</code>
block.
The job must include the following attributes in the
<code>
nest
</code>
block:
</p>
<ul>
<li>
<code>
parent
</code>
: This specifies the RDI data stream for the parent entities. Typically, you only
need to supply the parent
<code>
table
</code>
name, unless you are nesting children under a parent that comes from
a different source database. If you do this then you must also specify
<code>
server_name
</code>
and
<code>
schema
</code>
attributes.
</li>
<li>
<code>
nesting-key
</code>
: The field of the child entity that stores the unique ID (primary key) of the child entity.
</li>
<li>
<code>
parent-key
</code>
: The field in the parent entity that stores the unique ID (foreign key) of the parent entity.
</li>
<li>
<code>
child_key
</code>
: The field in the child entity that stores the unique ID (foreign key) of the parent entity.
You only need to add this attribute if the name of the child's foreign key field is different from the parent's.
</li>
<li>
<code>
path
</code>
: The
<a href="https://goessner.net/articles/JsonPath/">
JSONPath
</a>
for the map where you want to store the child entities. The path must start with the
<code>
$
</code>
character, which denotes
the document root.
</li>
<li>
<code>
structure
</code>
: (Optional) The type of JSON nesting structure for the child entities. Currently, only a JSON map
is supported so if you supply this attribute then the value must be
<code>
map
</code>
.
</li>
</ul>
<p>
There are several important things to note when you use nesting:
</p>
<ul>
<li>
<p>
When you specify
<code>
nest
</code>
in the job, you must also set the
<code>
data_type
</code>
attribute to
<code>
json
</code>
and
the
<code>
on_update
</code>
attribute to
<code>
merge
</code>
in the surrounding
<code>
output
</code>
block.
</p>
</li>
<li>
<p>
Key expressions are
<em>
not
</em>
supported for the
<code>
nest
</code>
output blocks. The parent key is always calculated
using the following template:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><nest.parent.table>:<nest.parent_key>:<nest.parent_key.value <span class="p">|</span> nest.child_key.value>
</span></span></code></pre>
</div>
<p>
For example:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">Invoice:InvoiceId:1
</span></span></code></pre>
</div>
</li>
<li>
<p>
If you specify
<code>
expire
</code>
in the
<code>
nest
</code>
output block then this will set the expiration on the
<em>
parent
</em>
object.
</p>
</li>
<li>
<p>
You can only use one level of nesting.
</p>
</li>
<li>
<p>
If you are using PostgreSQL then you must make the following change for all child tables that you want to nest:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">ALTER</span><span class="w"> </span><span class="k">TABLE</span><span class="w"> </span><span class="o"><</span><span class="k">TABLE_NAME</span><span class="o">></span><span class="w"> </span><span class="n">REPLICA</span><span class="w"> </span><span class="k">IDENTITY</span><span class="w"> </span><span class="k">FULL</span><span class="p">;</span><span class="w">
</span></span></span></code></pre>
</div>
<p>
This configuration affects the information written to the write-ahead log (WAL) and whether it is available
for RDI to capture. By default, PostgreSQL only records
modified fields in the log, which means that it might omit the
<code>
parent_key
</code>
. This can cause incorrect updates to the
Redis key in the destination database.
See the
<a href="https://debezium.io/documentation/reference/connectors/postgresql.html#postgresql-replica-identity">
Debezium PostgreSQL Connector Documentation
</a>
for more information about this.
</p>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redis-data-integration/data-pipelines/data-denormalization/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/requests/cluster/actions/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Cluster actions requests
</h1>
<p class="text-lg -mt-5 mb-10">
Cluster action requests
</p>
<table>
<thead>
<tr>
<th>
Method
</th>
<th>
Path
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#get-all-cluster-actions">
GET
</a>
</td>
<td>
<code>
/v1/cluster/actions
</code>
</td>
<td>
Get the status of all actions
</td>
</tr>
<tr>
<td>
<a href="#get-cluster-action">
GET
</a>
</td>
<td>
<code>
/v1/cluster/actions/{action}
</code>
</td>
<td>
Get the status of a specific action
</td>
</tr>
<tr>
<td>
<a href="#post-cluster-action">
POST
</a>
</td>
<td>
<code>
/v1/cluster/actions/{action}
</code>
</td>
<td>
Initiate a cluster-wide action
</td>
</tr>
<tr>
<td>
<a href="#delete-cluster-action">
DELETE
</a>
</td>
<td>
<code>
/v1/cluster/actions/{action}
</code>
</td>
<td>
Cancel action or remove action status
</td>
</tr>
</tbody>
</table>
<h2 id="get-all-cluster-actions">
Get all cluster actions
</h2>
<pre><code>GET /v1/cluster/actions
</code></pre>
<p>
Get the status of all currently executing, queued, or completed cluster actions.
</p>
<h4 id="required-permissions">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_status_of_cluster_action">
view_status_of_cluster_action
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-all-request">
Request
</h3>
<h4 id="example-http-request">
Example HTTP request
</h4>
<pre><code>GET /cluster/actions
</code></pre>
<h3 id="get-all-response">
Response
</h3>
<p>
Returns a JSON array of
<a href="/docs/latest/operate/rs/references/rest-api/objects/action/">
action objects
</a>
.
</p>
<h4 id="example-json-body">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"actions"</span><span class="p">:</span> <span class="p">[</span>
</span></span><span class="line"><span class="cl"> <span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"action_name"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span> <span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"progress"</span><span class="p">:</span> <span class="mf">0.0</span>
</span></span><span class="line"><span class="cl"> <span class="p">}</span>
</span></span><span class="line"><span class="cl"> <span class="p">]</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-all-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error, response provides info about an ongoing action.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Action does not exist (i.e. not currently running and no available status of last run).
</td>
</tr>
</tbody>
</table>
<h2 id="get-cluster-action">
Get cluster action
</h2>
<pre><code>GET /v1/cluster/actions/{action}
</code></pre>
<p>
Get the status of a currently executing, queued, or completed cluster action.
</p>
<h4 id="required-permissions-1">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#view_status_of_cluster_action">
view_status_of_cluster_action
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="get-request">
Request
</h3>
<h4 id="example-http-request-1">
Example HTTP request
</h4>
<pre><code>GET /cluster/actions/action_name
</code></pre>
<h4 id="url-parameters">
URL parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
action
</td>
<td>
string
</td>
<td>
The action to check.
</td>
</tr>
</tbody>
</table>
<h3 id="get-response">
Response
</h3>
<p>
Returns an
<a href="/docs/latest/operate/rs/references/rest-api/objects/action/">
action object
</a>
.
</p>
<h4 id="example-json-body-1">
Example JSON body
</h4>
<div class="highlight">
<pre class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"name"</span><span class="p">:</span> <span class="s2">"action_name"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"status"</span><span class="p">:</span> <span class="s2">"queued"</span><span class="p">,</span>
</span></span><span class="line"><span class="cl"> <span class="nt">"progress"</span><span class="p">:</span> <span class="mf">0.0</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre>
</div>
<h3 id="get-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error, response provides info about an ongoing action.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Action does not exist (i.e. not currently running and no available status of last run).
</td>
</tr>
</tbody>
</table>
<h2 id="post-cluster-action">
Initiate cluster-wide action
</h2>
<pre><code>POST /v1/cluster/actions/{action}
</code></pre>
<p>
Initiate a cluster-wide action.
</p>
<p>
The API allows only a single instance of any action type to be
invoked at the same time, and violations of this requirement will
result in a
<code>
409 CONFLICT
</code>
response.
</p>
<p>
The caller is expected to query and process the results of the
previously executed instance of the same action, which will be
removed as soon as the new one is submitted.
</p>
<h4 id="required-permissions-2">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#start_cluster_action">
start_cluster_action
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="post-request">
Request
</h3>
<h4 id="example-http-request-2">
Example HTTP request
</h4>
<pre><code>POST /cluster/actions/action_name
</code></pre>
<h4 id="url-parameters-1">
URL parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
action
</td>
<td>
string
</td>
<td>
The name of the action required.
</td>
</tr>
</tbody>
</table>
<p>
Supported cluster actions:
</p>
<ul>
<li>
<p>
<code>
change_master
</code>
: Promotes a specified node to become the primary node of the cluster, which coordinates cluster-wide operations. Include the
<code>
node_uid
</code>
of the node you want to promote in the request body.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">POST /v1/cluster/actions/change_master
</span></span><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="s2">"node_uid"</span>: <span class="s2">"2"</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre>
</div>
</li>
</ul>
<h3 id="post-response">
Response
</h3>
<p>
The body content may provide additional action details. Currently, it is not used.
</p>
<h3 id="post-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
No error, action was initiated.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1">
400 Bad Request
</a>
</td>
<td>
Bad action or content provided.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10">
409 Conflict
</a>
</td>
<td>
A conflicting action is already in progress.
</td>
</tr>
</tbody>
</table>
<h2 id="delete-cluster-action">
Cancel action
</h2>
<pre><code>DELETE /v1/cluster/actions/{action}
</code></pre>
<p>
Cancel a queued or executing cluster action, or remove the status of
a previously executed and completed action.
</p>
<h4 id="required-permissions-3">
Required permissions
</h4>
<table>
<thead>
<tr>
<th>
Permission name
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="/docs/latest/operate/rs/references/rest-api/permissions/#cancel_cluster_action">
cancel_cluster_action
</a>
</td>
</tr>
</tbody>
</table>
<h3 id="delete-request">
Request
</h3>
<h4 id="example-http-request-3">
Example HTTP request
</h4>
<pre><code>DELETE /v1/cluster/actions/action_name
</code></pre>
<h4 id="url-parameters-2">
URL parameters
</h4>
<table>
<thead>
<tr>
<th>
Field
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
action
</td>
<td>
string
</td>
<td>
The name of the action to cancel, currently no actions are supported.
</td>
</tr>
</tbody>
</table>
<h3 id="delete-response">
Response
</h3>
<p>
Returns a status code.
</p>
<h3 id="delete-status-codes">
Status codes
</h3>
<table>
<thead>
<tr>
<th>
Code
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1">
200 OK
</a>
</td>
<td>
Action will be cancelled when possible.
</td>
</tr>
<tr>
<td>
<a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5">
404 Not Found
</a>
</td>
<td>
Action unknown or not currently running.
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/requests/cluster/actions/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/upgrade/.html | <section class="prose w-full py-12 max-w-none">
<h1>
rladmin upgrade
</h1>
<p class="text-lg -mt-5 mb-10">
Upgrades the version of a module or Redis Enterprise Software for a database.
</p>
<p>
Upgrades the version of a module or Redis Enterprise Software for a database.
</p>
<h2 id="upgrade-db">
<code>
upgrade db
</code>
</h2>
<p>
Schedules a restart of the primary and replica processes of a database and then upgrades the database to the latest version of Redis Enterprise Software.
</p>
<p>
For more information, see
<a href="/docs/latest/operate/rs/installing-upgrading/upgrading/">
Upgrade an existing Redis Software Deployment
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin upgrade db <span class="o">{</span> db:<id> <span class="p">|</span> <name> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> preserve_roles <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> keep_redis_version <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> discard_data <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> force_discard <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> parallel_shards_upgrade <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> keep_crdt_protocol_version <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> redis_version <version> <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> force <span class="o">]</span>
</span></span><span class="line"><span class="cl"> <span class="o">[</span> <span class="o">{</span> latest_with_modules <span class="p">|</span> and module module_name <module name> version <version> module_args <arguments string> <span class="o">}</span> <span class="o">]</span>
</span></span></code></pre>
</div>
<p>
As of v6.2.4, the default behavior for
<code>
upgrade db
</code>
has changed. It is now controlled by a new parameter that sets the default upgrade policy used to create new databases and to upgrade ones already in the cluster. To learn more, see
<a href="/docs/latest/operate/rs/references/cli-utilities/rladmin/tune/#tune-cluster">
<code>
tune cluster default_redis_version
</code>
</a>
.
</p>
<p>
As of Redis Enterprise Software version 7.8.2,
<code>
upgrade db
</code>
will always upgrade modules.
</p>
<h3 id="parameters">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameters
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
db
</td>
<td>
db:<id>
<br/>
name
</td>
<td>
Database to upgrade
</td>
</tr>
<tr>
<td>
and module
</td>
<td>
<a href="#upgrade-module">
upgrade module
</a>
command
</td>
<td>
Clause that allows the upgrade of a database and a specified Redis module in a single step with only one restart (can be specified multiple times). Deprecated as of Redis Enterprise Software v7.8.2.
</td>
</tr>
<tr>
<td>
discard_data
</td>
<td>
</td>
<td>
Indicates that data will not be saved after the upgrade
</td>
</tr>
<tr>
<td>
force
</td>
<td>
</td>
<td>
Forces upgrade and skips warnings and confirmations
</td>
</tr>
<tr>
<td>
force_discard
</td>
<td>
</td>
<td>
Forces
<code>
discard_data
</code>
if replication or persistence is enabled
</td>
</tr>
<tr>
<td>
keep_crdt_protocol_version
</td>
<td>
</td>
<td>
Keeps the current CRDT protocol version
</td>
</tr>
<tr>
<td>
keep_redis_version
</td>
<td>
</td>
<td>
Upgrades to a new patch release, not to the latest major.minor version. Deprecated as of Redis Enterprise Software v7.8.2. To upgrade modules without upgrading the Redis database version, set
<code>
redis_version
</code>
to the current Redis database version instead.
</td>
</tr>
<tr>
<td>
latest_with_modules
</td>
<td>
</td>
<td>
Upgrades the Redis Enterprise Software version and all modules in the database. As of Redis Enterprise Software version 7.8.2,
<code>
upgrade db
</code>
will always upgrade modules.
</td>
</tr>
<tr>
<td>
parallel_shards_upgrade
</td>
<td>
integer
<br/>
'all'
</td>
<td>
Maximum number of shards to upgrade all at once
</td>
</tr>
<tr>
<td>
preserve_roles
</td>
<td>
</td>
<td>
Performs an additional failover to guarantee the shards' roles are preserved
</td>
</tr>
<tr>
<td>
redis_version
</td>
<td>
Redis version
</td>
<td>
Upgrades the database to the specified version instead of the latest version
</td>
</tr>
</tbody>
</table>
<h3 id="returns">
Returns
</h3>
<p>
Returns
<code>
Done
</code>
if the upgrade completed. Otherwise, it returns an error.
</p>
<h3 id="example">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin upgrade db db:5
</span></span><span class="line"><span class="cl">Monitoring e39c8e87-75f9-4891-8c86-78cf151b720b
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB init
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB check_slaves
</span></span><span class="line"><span class="cl">.active - SMUpgradeBDB prepare
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB stop_forwarding
</span></span><span class="line"><span class="cl">oactive - SMUpgradeBDB start_wd
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB wait_for_version
</span></span><span class="line"><span class="cl">.completed - SMUpgradeBDB
</span></span><span class="line"><span class="cl">Done
</span></span></code></pre>
</div>
<h2 id="upgrade-module">
<code>
upgrade module
</code>
</h2>
<p>
Upgrades Redis modules in use by a specific database. Deprecated as of Redis Enterprise Software v7.8.2. Use
<a href="#upgrade-db">
<code>
upgrade db
</code>
</a>
instead.
</p>
<p>
For more information, see
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/upgrade-module/">
Upgrade modules
</a>
.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin upgrade module
</span></span><span class="line"><span class="cl"> db_name <span class="o">{</span> db:<id> <span class="p">|</span> <name> <span class="o">}</span>
</span></span><span class="line"><span class="cl"> module_name <mod_name>
</span></span><span class="line"><span class="cl"> version <version>
</span></span><span class="line"><span class="cl"> module_args <args_str>
</span></span></code></pre>
</div>
<h3 id="parameters-1">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameters
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
db_name
</td>
<td>
db:<id>
<br/>
name
</td>
<td>
Upgrade a module for the specified database
</td>
</tr>
<tr>
<td>
module_name
</td>
<td>
'ReJSON'
<br/>
'graph'
<br/>
'search'
<br/>
'bf'
<br/>
'rg'
<br/>
'timeseries'
</td>
<td>
Redis module to upgrade
</td>
</tr>
<tr>
<td>
version
</td>
<td>
module version number
</td>
<td>
Upgrades the module to the specified version
</td>
</tr>
<tr>
<td>
module_args
</td>
<td>
'keep_args'
<br/>
string
</td>
<td>
Module configuration options
</td>
</tr>
</tbody>
</table>
<p>
For more information about module configuration options, see
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/install/add-module-to-database/#module-configuration-options">
Module configuration options
</a>
.
</p>
<h3 id="returns-1">
Returns
</h3>
<p>
Returns
<code>
Done
</code>
if the upgrade completed. Otherwise, it returns an error.
</p>
<h3 id="example-1">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin upgrade module db_name db:8 module_name graph version <span class="m">20812</span> module_args <span class="s2">""</span>
</span></span><span class="line"><span class="cl">Monitoring 21ac7659-e44c-4cc9-b243-a07922b2a6cc
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB init
</span></span><span class="line"><span class="cl">active - SMUpgradeBDB wait_for_version
</span></span><span class="line"><span class="cl">Ocompleted - SMUpgradeBDB
</span></span><span class="line"><span class="cl">Done
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/cli-utilities/rladmin/upgrade/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/brpoplpush/.html | <section class="prose w-full py-12">
<h1 class="command-name">
BRPOPLPUSH
<span class="text-base">
(deprecated)
</span>
</h1>
<div class="border-l-8 pl-4">
<p>
As of Redis version 6.2.0, this command is regarded as deprecated.
</p>
<p>
It can be replaced by
<a href="/docs/latest/commands/blmove/">
<code>
BLMOVE
</code>
</a>
with the
<code>
RIGHT
</code>
and
<code>
LEFT
</code>
arguments when migrating or writing new code.
</p>
</div>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">BRPOPLPUSH source destination timeout</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.2.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@write
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@list
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@blocking
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
<code>
BRPOPLPUSH
</code>
is the blocking variant of
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
.
When
<code>
source
</code>
contains elements, this command behaves exactly like
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
.
When used inside a
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
/
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
block, this command behaves exactly like
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
.
When
<code>
source
</code>
is empty, Redis will block the connection until another client
pushes to it or until
<code>
timeout
</code>
is reached.
A
<code>
timeout
</code>
of zero can be used to block indefinitely.
</p>
<p>
See
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
for more information.
</p>
<h2 id="pattern-reliable-queue">
Pattern: Reliable queue
</h2>
<p>
Please see the pattern description in the
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
documentation.
</p>
<h2 id="pattern-circular-list">
Pattern: Circular list
</h2>
<p>
Please see the pattern description in the
<a href="/docs/latest/commands/rpoplpush/">
<code>
RPOPLPUSH
</code>
</a>
documentation.
</p>
<h2 id="resp2-reply">
RESP2 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the element being popped from
<em>
source
</em>
and pushed to
<em>
destination
</em>
.
</li>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Nil reply
</a>
: the timeout is reached.
</li>
</ul>
<h2 id="resp3-reply">
RESP3 Reply
</h2>
<p>
One of the following:
</p>
<ul>
<li>
<a href="../../develop/reference/protocol-spec#bulk-strings">
Bulk string reply
</a>
: the element being popped from
<em>
source
</em>
and pushed to
<em>
destination
</em>
.
</li>
<li>
<a href="../../develop/reference/protocol-spec#nulls">
Null reply
</a>
: the timeout is reached.
</li>
</ul>
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 6.0.0:
<code>
timeout
</code>
is interpreted as a double instead of an integer.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/brpoplpush/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/api/get-started/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Get started with the REST API
</h1>
<p class="text-lg -mt-5 mb-10">
Describes how Redis Cloud REST API uses keys to authenticate and authorize access.
</p>
<p>
To use the Redis Cloud REST API, you need to:
</p>
<ul>
<li>
Enable the API
</li>
<li>
Create an account key
</li>
<li>
Create a user key
</li>
<li>
Collect endpoint details
</li>
</ul>
<p>
To use the keys to authenticate and authorize your request, include the keys with the request headers:
</p>
<table>
<thead>
<tr>
<th>
Key name
</th>
<th>
HTTPΒ headerΒ name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
AccountΒ key
</td>
<td>
<code>
x-api-key
</code>
</td>
<td>
Account-level key assigned to all users of an account
</td>
</tr>
<tr>
<td>
User key
</td>
<td>
<nobr>
<code>
x-api-secret-key
</code>
</nobr>
</td>
<td>
Personal key associated with a specific user and possibly limited to certain IP ranges
</td>
</tr>
</tbody>
</table>
<h2 id="enable-the-api">
Enable the API
</h2>
<p>
The API is disabled on all accounts by default. You must
<a href="/docs/latest/operate/rc/api/get-started/enable-the-api/">
enable the API
</a>
before you can use it.
</p>
<h2 id="account-key">
Account key
</h2>
<p>
The account key identifies your specific account when you perform an API request. This is the account responsible for your subscription.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
An account key is an account-level secret. Do not share this key with anyone not authorized to use the account.
</div>
</div>
<p>
You create the account key once when enabling API access.
</p>
<p>
If you need to change or delete your account key, please
<a href="https://redislabs.com/company/support/">
contact support
</a>
.
</p>
<h2 id="user-key">
User key
</h2>
<p>
The user key is a personal key that belongs to a specific user having the
<strong>
owner
</strong>
role. User keys are assigned owners when they're created. Keys cannot be assigned to users that aren't owners. Keys can belong to only one owner; however, an owner may have multiple keys.
</p>
<p>
You can view keys or copy their values
<em>
only
</em>
during the
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/">
creation process
</a>
.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
User keys are personal secrets. Do not share them.
</div>
</div>
<p>
Individual owners can
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/">
generate multiple user keys
</a>
for themselves, for separate apps, or for other owners within the same account.
</p>
<p>
Use key names to uniquely associate specific API requests to individual users or apps.
</p>
<p>
Doing so lets you
<a href="/docs/latest/operate/rc/api/examples/audit-system-logs/">
audit API requests
</a>
using the system log, which tracks the key used to authenticate each request.
</p>
<h2 id="authentication-using-api-keys">
Authentication using API keys
</h2>
<p>
Every API request must use the
<strong>
account key
</strong>
and a
<strong>
user key
</strong>
to authenticate.
</p>
<p>
The keys are provided as
<a href="/docs/latest/operate/rc/api/get-started/use-rest-api/#use-the-curl-http-client">
HTTP request headers
</a>
, shown earlier.
</p>
<h2 id="authenticate-a-request">
Authenticate a request
</h2>
<p>
An API request successfully authenticates when:
</p>
<ol>
<li>
<p>
The account and user keys are valid and properly defined in the HTTP request headers.
</p>
</li>
<li>
<p>
The user key is associated with the same account as the account key.
</p>
</li>
<li>
<p>
The request originates from a valid source IP address, as defined in a
<a href="https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing">
CIDR
</a>
allow list associated with the user key.
</p>
<p>
This requirement applies when you've
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/#manage-cidr-allow-list">
defined a CIDR allow list
</a>
for the secret key.
</p>
</li>
</ol>
<h2 id="more-info">
More info
</h2>
<p>
To learn more, see:
</p>
<ul>
<li>
<a href="/docs/latest/operate/rc/api/get-started/manage-api-keys/">
Manage API keys
</a>
</li>
<li>
<a href="/docs/latest/operate/rc/api/get-started/use-rest-api/">
Use the API
</a>
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/api/get-started/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/json.strappend/.html | <section class="prose w-full py-12">
<h1 class="command-name">
JSON.STRAPPEND
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">JSON.STRAPPEND key [path] value</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/json">
JSON 1.0.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key
</dd>
</dl>
<p>
Append the
<code>
json-string
</code>
values to the string at
<code>
path
</code>
</p>
<p>
<a href="#examples">
Examples
</a>
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
<p>
is key to modify.
</p>
</details>
<details open="">
<summary>
<code>
value
</code>
</summary>
<p>
is value to append to one or more strings.
</p>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
About using strings with JSON commands:
</div>
To specify a string as an array value to append, wrap the quoted string with an additional set of single quotes. Example:
<code>
'"silver"'
</code>
. For more detailed use, see
<a href="#examples">
Examples
</a>
.
</div>
</div>
</details>
<h2 id="optional-arguments">
Optional arguments
</h2>
<details open="">
<summary>
<code>
path
</code>
</summary>
<p>
is JSONPath to specify. Default is root
<code>
$
</code>
.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
JSON.STRAPPEND returns an array of integer replies for each path, the string's new length, or
<code>
nil
</code>
, if the matching JSON value is not a string.
For more information about replies, see
<a href="/docs/latest/develop/reference/protocol-spec/">
Redis serialization protocol specification
</a>
.
</p>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> JSON.SET doc $ <span class="s1">'{"a":"foo", "nested": {"a": "hello"}, "nested2": {"a": 31}}'</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> JSON.STRAPPEND doc $..a <span class="s1">'"baz"'</span>
</span></span><span class="line"><span class="cl">1<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">6</span>
</span></span><span class="line"><span class="cl">2<span class="o">)</span> <span class="o">(</span>integer<span class="o">)</span> <span class="m">8</span>
</span></span><span class="line"><span class="cl">3<span class="o">)</span> <span class="o">(</span>nil<span class="o">)</span>
</span></span><span class="line"><span class="cl">redis> JSON.GET doc $
</span></span><span class="line"><span class="cl"><span class="s2">"[{\"a\":\"foobaz\",\"nested\":{\"a\":\"hellobaz\"},\"nested2\":{\"a\":31}}]"</span></span></span></code></pre>
</div>
<h2 id="see-also">
See also
</h2>
<p>
<code>
JSON.ARRAPEND
</code>
|
<a href="/docs/latest/commands/json.arrinsert/">
<code>
JSON.ARRINSERT
</code>
</a>
</p>
<h2 id="related-topics">
Related topics
</h2>
<ul>
<li>
<a href="/docs/latest/develop/data-types/json/">
RedisJSON
</a>
</li>
<li>
<a href="/docs/latest/develop/interact/search-and-query/indexing/">
Index and search JSON documents
</a>
</li>
</ul>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/json.strappend/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-delete-context/.html | <section class="prose w-full py-12 max-w-none">
<h1>
redis-di delete-context
</h1>
<p class="text-lg -mt-5 mb-10">
Deletes a context
</p>
<h2 id="usage">
Usage
</h2>
<pre tabindex="0"><code>Usage: redis-di delete-context [OPTIONS] CONTEXT_NAME
</code></pre>
<h2 id="options">
Options
</h2>
<ul>
<li>
<p>
<code>
loglevel
</code>
:
</p>
<ul>
<li>
Type: Choice(['DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL'])
</li>
<li>
Default:
<code>
info
</code>
</li>
<li>
Usage:
<code>
--loglevel -log-level
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
context_name
</code>
(REQUIRED):
</p>
<ul>
<li>
Type: STRING
</li>
<li>
Default:
<code>
none
</code>
</li>
<li>
Usage:
<code>
context-name
</code>
</li>
</ul>
</li>
<li>
<p>
<code>
force
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--force -f
</code>
</li>
</ul>
<p>
Force operation. skips verification prompts
</p>
</li>
<li>
<p>
<code>
help
</code>
:
</p>
<ul>
<li>
Type: BOOL
</li>
<li>
Default:
<code>
false
</code>
</li>
<li>
Usage:
<code>
--help
</code>
</li>
</ul>
<p>
Show this message and exit.
</p>
</li>
</ul>
<h2 id="cli-help">
CLI help
</h2>
<pre tabindex="0"><code>Usage: redis-di delete-context [OPTIONS] CONTEXT_NAME
Deletes a context
Options:
-log-level, --loglevel [DEBUG|INFO|WARN|ERROR|CRITICAL]
[default: INFO]
-f, --force Force operation. skips verification prompts
--help Show this message and exit.
</code></pre>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/write-behind/reference/cli/redis-di-delete-context/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/tdigest.byrank/.html | <section class="prose w-full py-12">
<h1 class="command-name">
TDIGEST.BYRANK
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">TDIGEST.BYRANK key rank [rank ...]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available in:
</dt>
<dd class="m-0">
<a href="/docs/stack">
Redis Stack
</a>
/
<a href="/docs/data-types/probabilistic">
Bloom 2.4.0
</a>
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) where N is the number of ranks specified.
</dd>
</dl>
<p>
Returns, for each input rank, an estimation of the value (floating-point) with that rank.
</p>
<p>
Multiple estimations can be retrieved in a signle call.
</p>
<h2 id="required-arguments">
Required arguments
</h2>
<details open="">
<summary>
<code>
key
</code>
</summary>
is key name for an existing t-digest sketch.
</details>
<details open="">
<summary>
<code>
rank
</code>
</summary>
<p>
Rank, for which the value should be retrieved.
</p>
<p>
0 is the rank of the value of the smallest observation.
</p>
<p>
<em>
n
</em>
-1 is the rank of the value of the largest observation;
<em>
n
</em>
denotes the number of observations added to the sketch.
</p>
</details>
<h2 id="return-value">
Return value
</h2>
<p>
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
- an array of floating-points populated with value_1, value_2, ..., value_R:
</p>
<ul>
<li>
Return an accurate result when
<code>
rank
</code>
is 0 (the value of the smallest observation)
</li>
<li>
Return an accurate result when
<code>
rank
</code>
is
<em>
n
</em>
-1 (the value of the largest observation), where
<em>
n
</em>
denotes the number of observations added to the sketch.
</li>
<li>
Return 'inf' when
<code>
rank
</code>
is equal to
<em>
n
</em>
or larger than
<em>
n
</em>
</li>
</ul>
<p>
All values are 'nan' if the sketch is empty.
</p>
<h2 id="examples">
Examples
</h2>
<div class="highlight">
<pre class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">redis> TDIGEST.CREATE t COMPRESSION <span class="m">1000</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.ADD t <span class="m">1</span> <span class="m">2</span> <span class="m">2</span> <span class="m">3</span> <span class="m">3</span> <span class="m">3</span> <span class="m">4</span> <span class="m">4</span> <span class="m">4</span> <span class="m">4</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span> <span class="m">5</span>
</span></span><span class="line"><span class="cl">OK
</span></span><span class="line"><span class="cl">redis> TDIGEST.BYRANK t <span class="m">0</span> <span class="m">1</span> <span class="m">2</span> <span class="m">3</span> <span class="m">4</span> <span class="m">5</span> <span class="m">6</span> <span class="m">7</span> <span class="m">8</span> <span class="m">9</span> <span class="m">10</span> <span class="m">11</span> <span class="m">12</span> <span class="m">13</span> <span class="m">14</span> <span class="m">15</span>
</span></span><span class="line"><span class="cl"> 1<span class="o">)</span> <span class="s2">"1"</span>
</span></span><span class="line"><span class="cl"> 2<span class="o">)</span> <span class="s2">"2"</span>
</span></span><span class="line"><span class="cl"> 3<span class="o">)</span> <span class="s2">"2"</span>
</span></span><span class="line"><span class="cl"> 4<span class="o">)</span> <span class="s2">"3"</span>
</span></span><span class="line"><span class="cl"> 5<span class="o">)</span> <span class="s2">"3"</span>
</span></span><span class="line"><span class="cl"> 6<span class="o">)</span> <span class="s2">"3"</span>
</span></span><span class="line"><span class="cl"> 7<span class="o">)</span> <span class="s2">"4"</span>
</span></span><span class="line"><span class="cl"> 8<span class="o">)</span> <span class="s2">"4"</span>
</span></span><span class="line"><span class="cl"> 9<span class="o">)</span> <span class="s2">"4"</span>
</span></span><span class="line"><span class="cl">10<span class="o">)</span> <span class="s2">"4"</span>
</span></span><span class="line"><span class="cl">11<span class="o">)</span> <span class="s2">"5"</span>
</span></span><span class="line"><span class="cl">12<span class="o">)</span> <span class="s2">"5"</span>
</span></span><span class="line"><span class="cl">13<span class="o">)</span> <span class="s2">"5"</span>
</span></span><span class="line"><span class="cl">14<span class="o">)</span> <span class="s2">"5"</span>
</span></span><span class="line"><span class="cl">15<span class="o">)</span> <span class="s2">"5"</span>
</span></span><span class="line"><span class="cl">16<span class="o">)</span> <span class="s2">"inf"</span></span></span></code></pre>
</div>
<br/>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/tdigest.byrank/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/bitcount/.html | <section class="prose w-full py-12">
<h1 class="command-name">
BITCOUNT
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">BITCOUNT key [start end [BYTE | BIT]]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.6.0
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N)
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@read
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@bitmap
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Count the number of set bits (population counting) in a string.
</p>
<p>
By default all the bytes contained in the string are examined.
It is possible to specify the counting operation only in an interval passing the
additional arguments
<em>
start
</em>
and
<em>
end
</em>
.
</p>
<p>
Like for the
<a href="/docs/latest/commands/getrange/">
<code>
GETRANGE
</code>
</a>
command start and end can contain negative values in
order to index bytes starting from the end of the string, where -1 is the last
byte, -2 is the penultimate, and so forth.
</p>
<p>
Non-existent keys are treated as empty strings, so the command will return zero.
</p>
<p>
By default, the additional arguments
<em>
start
</em>
and
<em>
end
</em>
specify a byte index.
We can use an additional argument
<code>
BIT
</code>
to specify a bit index.
So 0 is the first bit, 1 is the second bit, and so forth.
For negative values, -1 is the last bit, -2 is the penultimate, and so forth.
</p>
<h2 id="examples">
Examples
</h2>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> SET mykey "foobar"
"OK"
redis> BITCOUNT mykey
(integer) 26
redis> BITCOUNT mykey 0 0
(integer) 4
redis> BITCOUNT mykey 1 1
(integer) 6
redis> BITCOUNT mykey 1 1 BYTE
(integer) 6
redis> BITCOUNT mykey 5 30 BIT
(integer) 17
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="pattern-real-time-metrics-using-bitmaps">
Pattern: real-time metrics using bitmaps
</h2>
<p>
Bitmaps are a very space-efficient representation of certain kinds of
information.
One example is a Web application that needs the history of user visits, so that
for instance it is possible to determine what users are good targets of beta
features.
</p>
<p>
Using the
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
command this is trivial to accomplish, identifying every day
with a small progressive integer.
For instance day 0 is the first day the application was put online, day 1 the
next day, and so forth.
</p>
<p>
Every time a user performs a page view, the application can register that in
the current day the user visited the web site using the
<a href="/docs/latest/commands/setbit/">
<code>
SETBIT
</code>
</a>
command setting
the bit corresponding to the current day.
</p>
<p>
Later it will be trivial to know the number of single days the user visited the
web site simply calling the
<code>
BITCOUNT
</code>
command against the bitmap.
</p>
<p>
A similar pattern where user IDs are used instead of days is described
in the article called "
<a href="http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps">
Fast easy realtime metrics using Redis
bitmaps
</a>
".
</p>
<h2 id="performance-considerations">
Performance considerations
</h2>
<p>
In the above example of counting days, even after 10 years the application is
online we still have just
<code>
365*10
</code>
bits of data per user, that is just 456 bytes
per user.
With this amount of data
<code>
BITCOUNT
</code>
is still as fast as any other O(1) Redis
command like
<a href="/docs/latest/commands/get/">
<code>
GET
</code>
</a>
or
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
.
</p>
<p>
When the bitmap is big, there are two alternatives:
</p>
<ul>
<li>
Taking a separated key that is incremented every time the bitmap is modified.
This can be very efficient and atomic using a small Redis Lua script.
</li>
<li>
Running the bitmap incrementally using the
<code>
BITCOUNT
</code>
<em>
start
</em>
and
<em>
end
</em>
optional parameters, accumulating the results client-side, and optionally
caching the result into a key.
</li>
</ul>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#integers">
Integer reply
</a>
: the number of bits set to 1.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Added the
<code>
BYTE|BIT
</code>
option.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/bitcount/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/security/access-control/data-access-control/configure-acls/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Configure permissions with Redis ACLs
</h1>
<p>
You can define custom Redis ACL rules to assign to a data access role or use predefined Redis ACLs.
</p>
<p>
Redis provides three predefined ACL rules, which are marked with the Redis logo and can not be changed:
</p>
<ul>
<li>
<strong>
Full-Access
</strong>
: Allows all commands.
</li>
<li>
<strong>
Read-Write
</strong>
: Allows read and write commands and excludes dangerous commands.
</li>
<li>
<strong>
Read-Only
</strong>
: Allows read commands only.
</li>
</ul>
<p>
ACLs that are not marked with the Redis logo are user-defined ACL rules.
</p>
<p>
To configure a Redis ACL that you can assign to a data access role:
</p>
<ol>
<li>
<p>
Go to
<strong>
Data Access Control
</strong>
from the
<a href="https://cloud.redis.io/#/">
Redis Cloud console
</a>
menu.
</p>
<a href="/docs/latest/images/rc/data-access-control-menu.png" sdata-lightbox="/images/rc/data-access-control-menu.png">
<img alt="Menu for database access control." src="/docs/latest/images/rc/data-access-control-menu.png" width="200px"/>
</a>
</li>
<li>
<p>
Select the
<strong>
Redis ACLs
</strong>
tab.
</p>
<a href="/docs/latest/images/rc/data-access-control-redis-acls.png" sdata-lightbox="/images/rc/data-access-control-redis-acls.png">
<img alt="Redis ACLs area." src="/docs/latest/images/rc/data-access-control-redis-acls.png"/>
</a>
</li>
<li>
<p>
Either select
<code>
+
</code>
to create a new Redis ACL or point to an existing ACL and select the pencil icon to edit it.
</p>
<a href="/docs/latest/images/rc/data-access-control-redis-acls-add-or-update.png" sdata-lightbox="/images/rc/data-access-control-redis-acls-add-or-update.png">
<img alt="Add or Update Redis ACL." src="/docs/latest/images/rc/data-access-control-redis-acls-add-or-update.png" width="400px"/>
</a>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
The built-in Redis ACLs can't be edited.
</div>
</div>
</li>
<li>
<p>
Provide a descriptive name and create the ACL rule
<a href="#define-permissions-with-acl-syntax">
using ACL syntax
</a>
.
</p>
<a href="/docs/latest/images/rc/data-access-control-redis-acls-add.png" sdata-lightbox="/images/rc/data-access-control-redis-acls-add.png">
<img alt="Add Redis ACL." src="/docs/latest/images/rc/data-access-control-redis-acls-add.png"/>
</a>
</li>
<li>
<p>
Select the check mark to save your changes. Your new Redis ACL should appear in the list.
</p>
<a href="/docs/latest/images/rc/data-access-control-redis-acls-saved.png" sdata-lightbox="/images/rc/data-access-control-redis-acls-saved.png">
<img alt="Saved Redis ACL." src="/docs/latest/images/rc/data-access-control-redis-acls-saved.png"/>
</a>
</li>
</ol>
<p>
After you create a Redis ACL, you can assign it to a role. Redis ACLs are not fully verified until they are assigned to a role. For more information, see
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/create-roles/">
Create roles
</a>
or
<a href="/docs/latest/operate/rc/security/access-control/data-access-control/active-active-roles/">
Active-Active access roles
</a>
for an
<a href="/docs/latest/operate/rc/databases/configuration/active-active-redis/">
Active-Active database
</a>
.
</p>
<h2 id="define-permissions-with-acl-syntax">
Define permissions with ACL syntax
</h2>
<p>
You can define these permissions using the
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#acl-rules">
Redis ACL syntax
</a>
. This syntax lets you concisely specify which commands, command categories, keys, and pub/sub channels to allow.
</p>
<ul>
<li>
<code>
+
</code>
<em>
includes
</em>
commands or command categories
</li>
<li>
<code>
-
</code>
<em>
excludes
</em>
commands or command categories
</li>
<li>
<code>
@
</code>
indicates a command category
</li>
<li>
<code>
~
</code>
defines a permitted key pattern
</li>
<li>
<code>
&
</code>
allows access to a
<a href="/docs/latest/develop/interact/pubsub/">
pub/sub channel
</a>
</li>
</ul>
<p>
The Redis Cloud console will validate your ACL syntax while you are typing.
</p>
<h3 id="command-acl-rules">
Command ACL rules
</h3>
<p>
A
<strong>
command
</strong>
can be any
<a href="/docs/latest/commands/">
Redis command
</a>
.
</p>
<p>
For example, this Redis ACL rule indicates that the
<code>
SET
</code>
command is permitted:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">+set
</span></span></code></pre>
</div>
<h3 id="command-category-acl-rules">
Command category ACL rules
</h3>
<p>
A
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#command-categories">
<strong>
command category
</strong>
</a>
is a predefined, named set of commands.
</p>
<p>
For example, the Redis commands that
read data are available in the
<code>
read
</code>
command category. This Redis ACL rule permits access to all read commands:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">+@read
</span></span></code></pre>
</div>
<p>
To find out which commands are included in the
<code>
read
</code>
command category, run the following command with
<a href="/docs/latest/operate/rs/references/cli-utilities/redis-cli/">
<code>
redis-cli
</code>
</a>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">ACL CAT <span class="nb">read</span>
</span></span></code></pre>
</div>
<h3 id="key-acl-rules">
Key ACL rules
</h3>
<p>
To specify which
<strong>
keys
</strong>
are accessible, use the
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#key-permissions">
key permissions syntax
</a>
.
</p>
<p>
The following ACL rule allows access to all keys:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">~*
</span></span></code></pre>
</div>
<p>
Whereas, this ACL rule only allows access to keys prefixed with
<code>
cache:
</code>
</p>
<pre tabindex="0"><code>~cache:*
</code></pre>
<p>
Starting with Redis 7.0, key patterns can also be used to define how a command is able to read or write a key.
</p>
<p>
The following ACL rule allows you to copy information from keys prefixed with
<code>
cache:
</code>
into keys prefixed with
<code>
app:
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">+@all ~app:* %R~cache:*
</span></span></code></pre>
</div>
<p>
For more information on how this works, see the
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#key-permissions">
key permissions syntax
</a>
.
</p>
<h3 id="pubsub-acl-rules">
Pub/sub ACL rules
</h3>
<p>
Pub/sub ACL rules determine which pub/sub channels a user can access. For more information see,
<a href="/docs/latest/develop/interact/pubsub/">
Redis pub/sub
</a>
</p>
<p>
For versions older than Redis 7.0, pub/sub is permissive and allows access to all channels by default.
</p>
<p>
Redis 7.0 makes pub/sub restrictive and blocks access to all channels in Redis Software. However, Redis Cloud still defaults to permissive pub/sub even for Redis 7.0 subscriptions.
</p>
<table>
<thead>
<tr>
<th style="text-align:center">
Redis
<br/>
version
</th>
<th>
Redis Community Edition
<br/>
pub/sub ACLs
</th>
<th>
Redis Cloud
<br/>
pub/sub ACLs
</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">
6.0
</td>
<td>
Not supported
</td>
<td>
Not supported
</td>
</tr>
<tr>
<td style="text-align:center">
6.2
</td>
<td>
Permissive
</td>
<td>
Permissive
</td>
</tr>
<tr>
<td style="text-align:center">
7.0
</td>
<td>
Restrictive
</td>
<td>
Permissive
</td>
</tr>
</tbody>
</table>
<h4 id="restrict-channel-access">
Restrict channel access
</h4>
<p>
To block access to all channels, use the following ACL rule:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">resetchannels
</span></span></code></pre>
</div>
<p>
If you want to limit access to specific channels, first include
<code>
resetchannels
</code>
. Then use
<code>
&
</code>
syntax to allow access to particular channels:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">resetchannels <span class="p">&</span>channel1 <span class="p">&</span>channel2
</span></span></code></pre>
</div>
<h4 id="allow-all-channels">
Allow all channels
</h4>
<p>
To make pub/sub explicitly permissive and allow users to access all channels, set the following rule:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">allchannels
</span></span></code></pre>
</div>
<h3 id="selectors">
Selectors
</h3>
<p>
Starting with Redis 7.0, Redis supports adding multiple sets of rules that are evaluated independently of each other, called
<a href="/docs/latest/operate/oss_and_stack/management/security/acl/#selectors">
selectors
</a>
.
</p>
<p>
The following ACL rule allows a user to execute
<code>
GET
</code>
on keys prefixed with
<code>
cache
</code>
and
<code>
SET
</code>
on keys prefixed with
<code>
app
</code>
:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">+GET ~cache:* (+SET ~app:*)
</span></span></code></pre>
</div>
<h3 id="predefined-permissions">
Predefined permissions
</h3>
<p>
Redis Cloud includes three predefined permissions:
</p>
<ul>
<li>
<p>
Full-Access (
<code>
+@all ~*
</code>
) - All commands are allowed for all keys.
</p>
</li>
<li>
<p>
Read-Write (
<code>
+@all -@dangerous ~*
</code>
) - All commands except for the
<code>
dangerous
</code>
command category are allowed for all keys.
</p>
</li>
<li>
<p>
Read-Only (
<code>
+@read ~*
</code>
) - Only the
<code>
read
</code>
command category is allowed for all keys.
</p>
</li>
</ul>
<h3 id="advanced-capability-command-permissions">
Advanced capability command permissions
</h3>
<p>
Note that you can define permissions for the Redis commands of any advanced capabilities that are part of your subscription;
however, these permissions can only be used for databases that support those capabilities.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/security/access-control/data-access-control/configure-acls/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/integrate/redisvl/api/query/filter.md.html | <section class="prose w-full py-12 max-w-none">
<h1>
API Guide
</h1>
<p class="text-lg -mt-5 mb-10">
The RedisVL API guide
</p>
<nav>
<a href="/docs/latest/integrate/redisvl/api/schema/">
Schema
</a>
<p>
The schema APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/query/">
Query
</a>
<p>
The query APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/searchindex/">
Search index
</a>
<p>
The search index APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/filter/">
Filter
</a>
<p>
The filter APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/vectorizer/">
Vectorizers
</a>
<p>
The vectorizer APIs
</p>
<a href="/docs/latest/integrate/redisvl/api/cache/">
LLMCache
</a>
<p>
The LLMCache APIs
</p>
</nav>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/integrate/redisvl/api/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/synchronization-mode/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Configure distributed synchronization
</h1>
<p class="text-lg -mt-5 mb-10">
How to configure distributed synchronization so that any available proxy endpoint can manage synchronization traffic.
</p>
<p>
Replicated databases, such as
<a href="/docs/latest/operate/rs/7.4/databases/import-export/replica-of/">
Replica Of
</a>
and
<a href="/docs/latest/operate/rs/7.4/databases/active-active/">
Active-Active
</a>
databases,
use proxy endpoints to synchronize database changes with the databases on other participating clusters.
</p>
<p>
To improve the throughput and lower the latency for synchronization traffic,
you can configure a replicated database to use distributed synchronization where any available proxy endpoint can manage synchronization traffic.
</p>
<p>
Every database by default has one proxy endpoint that manages client and synchronization communication with the database shards,
and that proxy endpoint is used for database synchronization.
This is called centralized synchronization.
</p>
<p>
To prepare a database to use distributed synchronization you must first make sure that the database
<a href="/docs/latest/operate/rs/7.4/databases/configure/proxy-policy/">
proxy policy
</a>
is defined so that either each node has a proxy endpoint or each primary (master) shard has a proxy endpoint.
After you have multiple proxies for the database,
you can configure the database synchronization to use distributed synchronization.
</p>
<h2 id="configure-distributed-synchronization">
Configure distributed synchronization
</h2>
<div class="alert p-3 relative flex flex-row items-center text-base bg-redis-pencil-200 rounded-md">
<div class="p-2 pr-5">
<svg fill="none" height="21" viewbox="0 0 21 21" width="21" xmlns="http://www.w3.org/2000/svg">
<circle cx="10.5" cy="10.5" r="9.75" stroke="currentColor" stroke-width="1.5">
</circle>
<path d="M10.5 14V16" stroke="currentColor" stroke-width="2">
</path>
<path d="M10.5 5V12" stroke="currentColor" stroke-width="2">
</path>
</svg>
</div>
<div class="p-1 pl-6 border-l border-l-redis-ink-900 border-opacity-50">
<div class="font-medium">
Note:
</div>
You may use the database name in place of
<code>
db:<ID>
</code>
in the following
<code>
rladmin
</code>
commands.
</div>
</div>
<p>
To configure distributed synchronization:
</p>
<ol>
<li>
<p>
To check the proxy policy for the database, run:
<code>
rladmin status
</code>
</p>
<p>
The output of the status command shows the list of endpoints on the cluster and the proxy policy for the endpoint.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">ENDPOINTS:
</span></span><span class="line"><span class="cl">DB:ID NAME ID NODE ROLE SSL
</span></span><span class="line"><span class="cl">db:1 db endpoint:1:1 node:1 all-master-shards No
</span></span></code></pre>
</div>
<p>
If the proxy policy (also known as a
<em>
role
</em>
) is
<code>
single
</code>
, configure the policy to
<code>
all-nodes
</code>
or
<code>
all-master-shards
</code>
according to your needs with the command:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin <span class="nb">bind</span> db db:<ID> endpoint <endpoint id> policy <all-master-shards<span class="p">|</span>all-nodes>
</span></span></code></pre>
</div>
</li>
<li>
<p>
To configure the database to use distributed synchronization, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune db db:<ID> syncer_mode distributed
</span></span></code></pre>
</div>
<p>
To change back to centralized synchronization, run:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin tune db db:<ID> syncer_mode centralized
</span></span></code></pre>
</div>
</li>
</ol>
<h2 id="verify-database-synchronization">
Verify database synchronization
</h2>
<p>
Use
<code>
rladmin
</code>
to verify a database synchronization role:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">rladmin info db db:<ID>
</span></span></code></pre>
</div>
<p>
The current database role is reported as the
<code>
syncer_mode
</code>
value:
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ rladmin info db db:<ID>
</span></span><span class="line"><span class="cl">db:<ID> <span class="o">[</span><db_name><span class="o">]</span>:
</span></span><span class="line"><span class="cl"> // <span class="o">(</span>Other settings removed<span class="o">)</span>
</span></span><span class="line"><span class="cl"> syncer_mode: centralized
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/databases/active-active/synchronization-mode/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/commands/command-info/.html | <section class="prose w-full py-12">
<h1 class="command-name">
COMMAND INFO
</h1>
<div class="font-semibold text-redis-ink-900">
Syntax
</div>
<pre class="command-syntax">COMMAND INFO [command-name [command-name ...]]</pre>
<dl class="grid grid-cols-[auto,1fr] gap-2 mb-12">
<dt class="font-semibold text-redis-ink-900 m-0">
Available since:
</dt>
<dd class="m-0">
2.8.13
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
Time complexity:
</dt>
<dd class="m-0">
O(N) where N is the number of commands to look up
</dd>
<dt class="font-semibold text-redis-ink-900 m-0">
ACL categories:
</dt>
<dd class="m-0">
<code>
@slow
</code>
<span class="mr-1 last:hidden">
,
</span>
<code>
@connection
</code>
<span class="mr-1 last:hidden">
,
</span>
</dd>
</dl>
<p>
Returns
<a href="/docs/latest/develop/reference/protocol-spec/#arrays">
Array reply
</a>
of details about multiple Redis commands.
</p>
<p>
Same result format as
<a href="/docs/latest/commands/command/">
<code>
COMMAND
</code>
</a>
except you can specify which commands
get returned.
</p>
<p>
If you request details about non-existing commands, their return
position will be nil.
</p>
<h2 id="examples">
Examples
</h2>
<div class="bg-slate-900 border-b border-slate-700 rounded-t-xl px-4 py-3 w-full flex">
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M2.5 10C2.5 5.85786 5.85786 2.5 10 2.5C14.1421 2.5 17.5 5.85786 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L18.6603 17.5L1.33975 17.5L10 2.5Z">
</path>
</svg>
<svg class="shrink-0 h-[1.0625rem] w-[1.0625rem] fill-slate-50" fill="currentColor" viewbox="0 0 20 20">
<path d="M10 2.5L12.0776 7.9322L17.886 8.22949L13.3617 11.8841L14.8738 17.5L10 14.3264L5.1262 17.5L6.63834 11.8841L2.11403 8.22949L7.92238 7.9322L10 2.5Z">
</path>
</svg>
</div>
<form class="redis-cli overflow-y-auto max-h-80">
<pre tabindex="0">redis> COMMAND INFO get set eval
1) 1) "get"
2) (integer) 2
3) 1) "readonly"
2) "fast"
4) (integer) 1
5) (integer) 1
6) (integer) 1
7) 1) "@read"
2) "@string"
3) "@fast"
8) (empty array)
9) 1) 1) "flags"
2) 1) "RO"
2) "access"
3) "begin_search"
4) 1) "type"
2) "index"
3) "spec"
4) 1) "index"
2) (integer) 1
5) "find_keys"
6) 1) "type"
2) "range"
3) "spec"
4) 1) "lastkey"
2) (integer) 0
3) "keystep"
4) (integer) 1
5) "limit"
6) (integer) 0
10) (empty array)
2) 1) "set"
2) (integer) -3
3) 1) "write"
2) "denyoom"
4) (integer) 1
5) (integer) 1
6) (integer) 1
7) 1) "@write"
2) "@string"
3) "@slow"
8) (empty array)
9) 1) 1) "notes"
2) "RW and ACCESS due to the optional `GET` argument"
3) "flags"
4) 1) "RW"
2) "access"
3) "update"
4) "variable_flags"
5) "begin_search"
6) 1) "type"
2) "index"
3) "spec"
4) 1) "index"
2) (integer) 1
7) "find_keys"
8) 1) "type"
2) "range"
3) "spec"
4) 1) "lastkey"
2) (integer) 0
3) "keystep"
4) (integer) 1
5) "limit"
6) (integer) 0
10) (empty array)
3) 1) "eval"
2) (integer) -3
3) 1) "noscript"
2) "stale"
3) "skip_monitor"
4) "no_mandatory_keys"
5) "movablekeys"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@slow"
2) "@scripting"
8) (empty array)
9) 1) 1) "notes"
2) "We cannot tell how the keys will be used so we assume the worst, RW and UPDATE"
3) "flags"
4) 1) "RW"
2) "access"
3) "update"
5) "begin_search"
6) 1) "type"
2) "index"
3) "spec"
4) 1) "index"
2) (integer) 2
7) "find_keys"
8) 1) "type"
2) "keynum"
3) "spec"
4) 1) "keynumidx"
2) (integer) 0
3) "firstkey"
4) (integer) 1
5) "keystep"
6) (integer) 1
10) (empty array)
redis> COMMAND INFO foo evalsha config bar
1) (nil)
2) 1) "evalsha"
2) (integer) -3
3) 1) "noscript"
2) "stale"
3) "skip_monitor"
4) "no_mandatory_keys"
5) "movablekeys"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@slow"
2) "@scripting"
8) (empty array)
9) 1) 1) "flags"
2) 1) "RW"
2) "access"
3) "update"
3) "begin_search"
4) 1) "type"
2) "index"
3) "spec"
4) 1) "index"
2) (integer) 2
5) "find_keys"
6) 1) "type"
2) "keynum"
3) "spec"
4) 1) "keynumidx"
2) (integer) 0
3) "firstkey"
4) (integer) 1
5) "keystep"
6) (integer) 1
10) (empty array)
3) 1) "config"
2) (integer) -2
3) (empty array)
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@slow"
8) (empty array)
9) (empty array)
10) 1) 1) "config|get"
2) (integer) -3
3) 1) "admin"
2) "noscript"
3) "loading"
4) "stale"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@admin"
2) "@slow"
3) "@dangerous"
8) (empty array)
9) (empty array)
10) (empty array)
2) 1) "config|resetstat"
2) (integer) 2
3) 1) "admin"
2) "noscript"
3) "loading"
4) "stale"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@admin"
2) "@slow"
3) "@dangerous"
8) 1) "request_policy:all_nodes"
2) "response_policy:all_succeeded"
9) (empty array)
10) (empty array)
3) 1) "config|rewrite"
2) (integer) 2
3) 1) "admin"
2) "noscript"
3) "loading"
4) "stale"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@admin"
2) "@slow"
3) "@dangerous"
8) 1) "request_policy:all_nodes"
2) "response_policy:all_succeeded"
9) (empty array)
10) (empty array)
4) 1) "config|help"
2) (integer) 2
3) 1) "loading"
2) "stale"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@slow"
8) (empty array)
9) (empty array)
10) (empty array)
5) 1) "config|set"
2) (integer) -4
3) 1) "admin"
2) "noscript"
3) "loading"
4) "stale"
4) (integer) 0
5) (integer) 0
6) (integer) 0
7) 1) "@admin"
2) "@slow"
3) "@dangerous"
8) 1) "request_policy:all_nodes"
2) "response_policy:all_succeeded"
9) (empty array)
10) (empty array)
4) (nil)
</pre>
<div class="prompt" style="">
<span>
redis>
</span>
<input autocomplete="off" name="prompt" spellcheck="false" type="text"/>
</div>
</form>
<h2 id="resp2resp3-reply">
RESP2/RESP3 Reply
</h2>
<a href="../../develop/reference/protocol-spec#arrays">
Array reply
</a>
: a nested list of command details.
<br/>
<h2>
History
</h2>
<ul>
<li>
Starting with Redis version 7.0.0: Allowed to be called with no argument to get info on all commands.
</li>
</ul>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/commands/command-info/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/interact/transactions/.html | <section class="prose w-full py-12">
<h1>
Transactions
</h1>
<p class="text-lg -mt-5 mb-10">
How transactions work in Redis
</p>
<p>
Redis Transactions allow the execution of a group of commands
in a single step, they are centered around the commands
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
,
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
,
<a href="/docs/latest/commands/discard/">
<code>
DISCARD
</code>
</a>
and
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
.
Redis Transactions make two important guarantees:
</p>
<ul>
<li>
<p>
All the commands in a transaction are serialized and executed
sequentially. A request sent by another client will never be
served
<strong>
in the middle
</strong>
of the execution of a Redis Transaction.
This guarantees that the commands are executed as a single
isolated operation.
</p>
</li>
<li>
<p>
The
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
command
triggers the execution of all the commands in the transaction, so
if a client loses the connection to the server in the context of a
transaction before calling the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
command none of the operations
are performed, instead if the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
command is called, all the
operations are performed. When using the
<a href="/docs/latest/operate/oss_and_stack/management/persistence/#append-only-file">
append-only file
</a>
Redis makes sure
to use a single write(2) syscall to write the transaction on disk.
However if the Redis server crashes or is killed by the system administrator
in some hard way it is possible that only a partial number of operations
are registered. Redis will detect this condition at restart, and will exit with an error.
Using the
<code>
redis-check-aof
</code>
tool it is possible to fix the
append only file that will remove the partial transaction so that the
server can start again.
</p>
</li>
</ul>
<p>
Starting with version 2.2, Redis allows for an extra guarantee to the
above two, in the form of optimistic locking in a way very similar to a
check-and-set (CAS) operation.
This is documented
<a href="#cas">
later
</a>
on this page.
</p>
<h2 id="usage">
Usage
</h2>
<p>
A Redis Transaction is entered using the
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
command. The command
always replies with
<code>
OK
</code>
. At this point the user can issue multiple
commands. Instead of executing these commands, Redis will queue
them. All the commands are executed once
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called.
</p>
<p>
Calling
<a href="/docs/latest/commands/discard/">
<code>
DISCARD
</code>
</a>
instead will flush the transaction queue and will exit
the transaction.
</p>
<p>
The following example increments keys
<code>
foo
</code>
and
<code>
bar
</code>
atomically.
</p>
<pre tabindex="0"><code>> MULTI
OK
> INCR foo
QUEUED
> INCR bar
QUEUED
> EXEC
1) (integer) 1
2) (integer) 1
</code></pre>
<p>
As is clear from the session above,
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
returns an
array of replies, where every element is the reply of a single command
in the transaction, in the same order the commands were issued.
</p>
<p>
When a Redis connection is in the context of a
<a href="/docs/latest/commands/multi/">
<code>
MULTI
</code>
</a>
request,
all commands will reply with the string
<code>
QUEUED
</code>
(sent as a Status Reply
from the point of view of the Redis protocol). A queued command is
simply scheduled for execution when
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called.
</p>
<h2 id="errors-inside-a-transaction">
Errors inside a transaction
</h2>
<p>
During a transaction it is possible to encounter two kind of command errors:
</p>
<ul>
<li>
A command may fail to be queued, so there may be an error before
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called.
For instance the command may be syntactically wrong (wrong number of arguments,
wrong command name, ...), or there may be some critical condition like an out of
memory condition (if the server is configured to have a memory limit using the
<code>
maxmemory
</code>
directive).
</li>
<li>
A command may fail
<em>
after
</em>
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called, for instance since we performed
an operation against a key with the wrong value (like calling a list operation against a string value).
</li>
</ul>
<p>
Starting with Redis 2.6.5, the server will detect an error during the accumulation of commands.
It will then refuse to execute the transaction returning an error during
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
, discarding the transaction.
</p>
<blockquote>
<p>
<strong>
Note for Redis < 2.6.5:
</strong>
Prior to Redis 2.6.5 clients needed to detect errors occurring prior to
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
by checking
the return value of the queued command: if the command replies with QUEUED it was
queued correctly, otherwise Redis returns an error.
If there is an error while queueing a command, most clients
will abort and discard the transaction. Otherwise, if the client elected to proceed with the transaction
the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
command would execute all commands queued successfully regardless of previous errors.
</p>
</blockquote>
<p>
Errors happening
<em>
after
</em>
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
instead are not handled in a special way:
all the other commands will be executed even if some command fails during the transaction.
</p>
<p>
This is more clear on the protocol level. In the following example one
command will fail when executed even if the syntax is right:
</p>
<pre tabindex="0"><code>Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
MULTI
+OK
SET a abc
+QUEUED
LPOP a
+QUEUED
EXEC
*2
+OK
-WRONGTYPE Operation against a key holding the wrong kind of value
</code></pre>
<p>
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
returned two-element
<a href="/docs/latest/develop/reference/protocol-spec/#bulk-string-reply">
bulk string reply
</a>
where one is an
<code>
OK
</code>
code and
the other an error reply. It's up to the client library to find a
sensible way to provide the error to the user.
</p>
<p>
It's important to note that
<strong>
even when a command fails, all the other commands in the queue are processed
</strong>
β Redis will
<em>
not
</em>
stop the
processing of commands.
</p>
<p>
Another example, again using the wire protocol with
<code>
telnet
</code>
, shows how
syntax errors are reported ASAP instead:
</p>
<pre tabindex="0"><code>MULTI
+OK
INCR a b c
-ERR wrong number of arguments for 'incr' command
</code></pre>
<p>
This time due to the syntax error the bad
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
command is not queued
at all.
</p>
<h2 id="what-about-rollbacks">
What about rollbacks?
</h2>
<p>
Redis does not support rollbacks of transactions since supporting rollbacks
would have a significant impact on the simplicity and performance of Redis.
</p>
<h2 id="discarding-the-command-queue">
Discarding the command queue
</h2>
<p>
<a href="/docs/latest/commands/discard/">
<code>
DISCARD
</code>
</a>
can be used in order to abort a transaction. In this case, no
commands are executed and the state of the connection is restored to
normal.
</p>
<pre tabindex="0"><code>> SET foo 1
OK
> MULTI
OK
> INCR foo
QUEUED
> DISCARD
OK
> GET foo
"1"
</code></pre>
<p>
<a name="cas">
</a>
</p>
<h2 id="optimistic-locking-using-check-and-set">
Optimistic locking using check-and-set
</h2>
<p>
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
is used to provide a check-and-set (CAS) behavior to Redis
transactions.
</p>
<p>
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
ed keys are monitored in order to detect changes against them. If
at least one watched key is modified before the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
command, the
whole transaction aborts, and
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
returns a
<a href="/docs/latest/develop/reference/protocol-spec/#nil-reply">
Null reply
</a>
to notify that
the transaction failed.
</p>
<p>
For example, imagine we have the need to atomically increment the value
of a key by 1 (let's suppose Redis doesn't have
<a href="/docs/latest/commands/incr/">
<code>
INCR
</code>
</a>
).
</p>
<p>
The first try may be the following:
</p>
<pre tabindex="0"><code>val = GET mykey
val = val + 1
SET mykey $val
</code></pre>
<p>
This will work reliably only if we have a single client performing the
operation in a given time. If multiple clients try to increment the key
at about the same time there will be a race condition. For instance,
client A and B will read the old value, for instance, 10. The value will
be incremented to 11 by both the clients, and finally
<a href="/docs/latest/commands/set/">
<code>
SET
</code>
</a>
as the value
of the key. So the final value will be 11 instead of 12.
</p>
<p>
Thanks to
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
we are able to model the problem very well:
</p>
<pre tabindex="0"><code>WATCH mykey
val = GET mykey
val = val + 1
MULTI
SET mykey $val
EXEC
</code></pre>
<p>
Using the above code, if there are race conditions and another client
modifies the result of
<code>
val
</code>
in the time between our call to
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
and
our call to
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
, the transaction will fail.
</p>
<p>
We just have to repeat the operation hoping this time we'll not get a
new race. This form of locking is called
<em>
optimistic locking
</em>
.
In many use cases, multiple clients will be accessing different keys,
so collisions are unlikely β usually there's no need to repeat the operation.
</p>
<h2 id="watch-explained">
WATCH explained
</h2>
<p>
So what is
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
really about? It is a command that will
make the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
conditional: we are asking Redis to perform
the transaction only if none of the
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
ed keys were modified. This includes
modifications made by the client, like write commands, and by Redis itself,
like expiration or eviction. If keys were modified between when they were
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
ed and when the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
was received, the entire transaction will be aborted
instead.
</p>
<p>
<strong>
NOTE
</strong>
</p>
<ul>
<li>
In Redis versions before 6.0.9, an expired key would not cause a transaction
to be aborted.
<a href="https://github.com/redis/redis/pull/7920">
More on this
</a>
</li>
<li>
Commands within a transaction won't trigger the
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
condition since they
are only queued until the
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is sent.
</li>
</ul>
<p>
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
can be called multiple times. Simply all the
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
calls will
have the effects to watch for changes starting from the call, up to
the moment
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called. You can also send any number of keys to a
single
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
call.
</p>
<p>
When
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
is called, all keys are
<a href="/docs/latest/commands/unwatch/">
<code>
UNWATCH
</code>
</a>
ed, regardless of whether
the transaction was aborted or not. Also when a client connection is
closed, everything gets
<a href="/docs/latest/commands/unwatch/">
<code>
UNWATCH
</code>
</a>
ed.
</p>
<p>
It is also possible to use the
<a href="/docs/latest/commands/unwatch/">
<code>
UNWATCH
</code>
</a>
command (without arguments)
in order to flush all the watched keys. Sometimes this is useful as we
optimistically lock a few keys, since possibly we need to perform a
transaction to alter those keys, but after reading the current content
of the keys we don't want to proceed. When this happens we just call
<a href="/docs/latest/commands/unwatch/">
<code>
UNWATCH
</code>
</a>
so that the connection can already be used freely for new
transactions.
</p>
<h3 id="using-watch-to-implement-zpop">
Using WATCH to implement ZPOP
</h3>
<p>
A good example to illustrate how
<a href="/docs/latest/commands/watch/">
<code>
WATCH
</code>
</a>
can be used to create new
atomic operations otherwise not supported by Redis is to implement ZPOP
(
<a href="/docs/latest/commands/zpopmin/">
<code>
ZPOPMIN
</code>
</a>
,
<a href="/docs/latest/commands/zpopmax/">
<code>
ZPOPMAX
</code>
</a>
and their blocking variants have only been added
in version 5.0), that is a command that pops the element with the lower
score from a sorted set in an atomic way. This is the simplest
implementation:
</p>
<pre tabindex="0"><code>WATCH zset
element = ZRANGE zset 0 0
MULTI
ZREM zset element
EXEC
</code></pre>
<p>
If
<a href="/docs/latest/commands/exec/">
<code>
EXEC
</code>
</a>
fails (i.e. returns a
<a href="/docs/latest/develop/reference/protocol-spec/#nil-reply">
Null reply
</a>
) we just repeat the operation.
</p>
<h2 id="redis-scripting-and-transactions">
Redis scripting and transactions
</h2>
<p>
Something else to consider for transaction like operations in redis are
<a href="/docs/latest/commands/eval/">
redis scripts
</a>
which are transactional. Everything
you can do with a Redis Transaction, you can also do with a script, and
usually the script will be both simpler and faster.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/transactions/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/spellcheck/.html | <section class="prose w-full py-12">
<h1>
Spellchecking
</h1>
<p class="text-lg -mt-5 mb-10">
Query spelling correction support
</p>
<p>
Query spelling correction provides suggestions for misspelled search terms. For example, the term 'reids' may be a misspelled version of 'redis'.
</p>
<p>
In such cases, and as of v1.4, RediSearch can be used for generating alternatives to misspelled query terms. A misspelled term is a full text term (i.e., a word) that is:
</p>
<ol>
<li>
Not a stop word
</li>
<li>
Not in the index
</li>
<li>
At least 3 characters long
</li>
</ol>
<p>
The alternatives for a misspelled term are generated from the corpus of already-indexed terms and, optionally, one or more custom dictionaries. Alternatives become spelling suggestions based on their respective Levenshtein distances from the misspelled term. Each spelling suggestion is given a normalized score based on its occurrences in the index.
</p>
<p>
To obtain the spelling corrections for a query, refer to the documentation of the
<a href="/docs/latest/commands/ft.spellcheck/">
<code>
FT.SPELLCHECK
</code>
</a>
command.
</p>
<h2 id="custom-dictionaries">
Custom dictionaries
</h2>
<p>
A dictionary is a set of terms. Dictionaries can be added with terms, have terms deleted from them, and have their entire contents dumped using the
<a href="/docs/latest/commands/ft.dictadd/">
<code>
FT.DICTADD
</code>
</a>
,
<a href="/docs/latest/commands/ft.dictdel/">
<code>
FT.DICTDEL
</code>
</a>
and
<a href="/docs/latest/commands/ft.dictdump/">
<code>
FT.DICTDUMP
</code>
</a>
commands, respectively.
</p>
<p>
Dictionaries can be used to modify the behavior of spelling corrections by including or excluding their contents from potential spelling correction suggestions.
</p>
<p>
When used for term inclusion, the terms in a dictionary can be provided as spelling suggestions regardless of their occurrence in the index. Scores of suggestions from inclusion dictionaries are always 0.
</p>
<p>
Conversely, terms in an exclusion dictionary will never be returned as spelling alternatives.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/spellcheck/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/task/status/.html | <section class="prose w-full py-12 max-w-none">
<h1>
crdb-cli task status
</h1>
<p class="text-lg -mt-5 mb-10">
Shows the status of a specified Active-Active database task.
</p>
<p>
Shows the status of a specified Active-Active database task.
</p>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">crdb-cli task status --task-id <task_id>
</span></span></code></pre>
</div>
<h3 id="parameters">
Parameters
</h3>
<table>
<thead>
<tr>
<th>
Parameter
</th>
<th>
Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
task-id <task_id>
</td>
<td>
string
</td>
<td>
An Active-Active database task ID (required)
</td>
</tr>
<tr>
<td>
verbose
</td>
<td>
N/A
</td>
<td>
Returns detailed information when specified
</td>
</tr>
<tr>
<td>
no-verbose
</td>
<td>
N/A
</td>
<td>
Returns limited information when specified
</td>
</tr>
</tbody>
</table>
<p>
The
<code>
--verbose
</code>
and
<code>
--no-verbose
</code>
options are mutually incompatible; specify one or the other.
</p>
<p>
The
<code>
404 Not Found
</code>
error indicates an invalid task ID. Use the
<a href="/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/task/list/">
<code>
task list
</code>
</a>
command to determine available task IDs.
</p>
<h3 id="returns">
Returns
</h3>
<p>
Returns the status of an Active-Active database task.
</p>
<h3 id="example">
Example
</h3>
<div class="highlight">
<pre class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">$ crdb-cli task status --task-id e1c49470-ae0b-4df8-885b-9c755dd614d0
</span></span><span class="line"><span class="cl">Task-ID: e1c49470-ae0b-4df8-885b-9c755dd614d0
</span></span><span class="line"><span class="cl">CRDB-GUID: 1d7741cc-1110-4e2f-bc6c-935292783d24
</span></span><span class="line"><span class="cl">Operation: create_crdb
</span></span><span class="line"><span class="cl">Status: finished
</span></span><span class="line"><span class="cl">Worker-Name: crdb_worker:1:0
</span></span><span class="line"><span class="cl">Started: 2022-10-12T09:33:41Z
</span></span><span class="line"><span class="cl">Ended: 2022-10-12T09:33:55Z
</span></span></code></pre>
</div>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/7.4/references/cli-utilities/crdb-cli/task/status/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rs/references/rest-api/objects/job_scheduler/redis_cleanup_job_settings/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis cleanup job settings object
</h1>
<p class="text-lg -mt-5 mb-10">
Documents the redis_cleanup_job_settings object used with Redis Enterprise Software REST API calls.
</p>
<p>
Deprecated and replaced with
<code>
persistence_cleanup_scan_interval
</code>
.
</p>
<table>
<thead>
<tr>
<th>
Name
</th>
<th>
Type/Value
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
cron_expression
</td>
<td>
string
</td>
<td>
<a href="https://en.wikipedia.org/wiki/Cron#CRON_expression">
CRON expression
</a>
that defines the Redis cleanup schedule
</td>
</tr>
</tbody>
</table>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rs/references/rest-api/objects/job_scheduler/redis_cleanup_job_settings/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/databases/tag-database/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Manage database tags
</h1>
<p>
Tags are key-value pairs that let you categorize your databases. You can create tags and add them to your databases to associate them with each other. Once you've added tags, you can filter your databases in the
<a href="/docs/latest/operate/rc/databases/view-edit-database/#manage-the-database-list">
database list
</a>
by tag key or value.
</p>
<h2 id="manage-tags">
Manage tags
</h2>
<p>
You can manage tags from the
<a href="https://cloud.redis.io/#/">
Redis Cloud console
</a>
in the
<a href="#tag-manager">
tag manager
</a>
. You can find the tag manager in the following places:
</p>
<ul>
<li>
<a href="#configuration-tab">
From your database in the
<strong>
Configuration
</strong>
tab
</a>
</li>
<li>
<a href="#database-list">
From the database list
</a>
</li>
</ul>
<p>
After you open the
<a href="#tag-manager">
tag manager
</a>
, you can use it to add, edit, or delete tags.
</p>
<h3 id="configuration-tab">
Open tag manager from the Configuration tab
</h3>
<p>
To learn how to navigate to your database, see
<a href="/docs/latest/operate/rc/databases/view-edit-database/">
View and edit databases
</a>
. Select the
<strong>
Configuration
</strong>
tab and go to the
<strong>
General
</strong>
section to view the tags that are set for your database.
</p>
<a href="/docs/latest/images/rc/database-details-configuration-tab-general-flexible.png" sdata-lightbox="/images/rc/database-details-configuration-tab-general-flexible.png">
<img alt="The Configuration tab of the Database details screen." src="/docs/latest/images/rc/database-details-configuration-tab-general-flexible.png"/>
</a>
<p>
Select
<strong>
Manage Tags
</strong>
to open the
<a href="#tag-manager">
tag manager
</a>
.
</p>
<a href="/docs/latest/images/rc/tags-button-manage-tags.png" sdata-lightbox="/images/rc/tags-button-manage-tags.png">
<img alt="The Manage tags button." src="/docs/latest/images/rc/tags-button-manage-tags.png" width="120px"/>
</a>
<h3 id="database-list">
Open tag manager from the database list
</h3>
<p>
Using the database list allows you to manage tags for multiple databases without having to go into each database's
<strong>
Tags
</strong>
tab.
</p>
<p>
To get to the database list, select
<strong>
Databases
</strong>
from the main menu.
</p>
<a href="/docs/latest/images/rc/tags-database-list.png" sdata-lightbox="/images/rc/tags-database-list.png">
<img alt="The database list with databases that are tagged." src="/docs/latest/images/rc/tags-database-list.png"/>
</a>
<p>
Hover over the database and select
<strong>
Manage tags
</strong>
, or select
<strong>
More actions
</strong>
>
<strong>
Manage tags
</strong>
to open the
<a href="#tag-manager">
tag manager
</a>
.
</p>
<p>
<a href="/docs/latest/images/rc/tags-icon-manage-tags.png#no-click" sdata-lightbox="/images/rc/tags-icon-manage-tags.png#no-click">
<img alt="Manage tags button." class="inline" src="/docs/latest/images/rc/tags-icon-manage-tags.png#no-click" width="30px"/>
</a>
<a href="/docs/latest/images/rc/tags-icon-more-actions.png#no-click" sdata-lightbox="/images/rc/tags-icon-more-actions.png#no-click">
<img alt="More actions button." class="inline" src="/docs/latest/images/rc/tags-icon-more-actions.png#no-click" width="30px"/>
</a>
</p>
<h3 id="tag-manager">
Use the tag manager
</h3>
<p>
The tag manager shows any tags that are associated with the database and allows you to create, edit, or delete tags.
</p>
<a href="/docs/latest/images/rc/tags-tag-manager.png" sdata-lightbox="/images/rc/tags-tag-manager.png">
<img alt="The tag manager." src="/docs/latest/images/rc/tags-tag-manager.png"/>
</a>
<p>
You can select the tag's
<strong>
Key
</strong>
and
<strong>
Value
</strong>
from the suggestions, or you can enter your own.
</p>
<a href="/docs/latest/images/rc/tags-new-tag.png" sdata-lightbox="/images/rc/tags-new-tag.png">
<img alt="The New tag fields." src="/docs/latest/images/rc/tags-new-tag.png"/>
</a>
<p>
A valid tag must follow these guidelines:
</p>
<ul>
<li>
Tag keys must be between 1 and 64 characters long, and values must be at least 1 character long.
</li>
<li>
Tags can only have lowercase letters, numbers, spaces, and these special characters:
<code>
-
</code>
,
<code>
_
</code>
,
<code>
.
</code>
,
<code>
+
</code>
,
<code>
@
</code>
, and
<code>
:
</code>
.
</li>
</ul>
<p>
After you add your first tag, you can:
</p>
<ul>
<li>
<p>
Select the
<strong>
Key
</strong>
or
<strong>
Value
</strong>
field of an existing tag and enter new text to edit it.
</p>
</li>
<li>
<p>
Select
<strong>
Delete
</strong>
next to a tag to delete it.
</p>
<a href="/docs/latest/images/rc/tags-icon-delete.png" sdata-lightbox="/images/rc/tags-icon-delete.png">
<img alt="Delete button." src="/docs/latest/images/rc/tags-icon-delete.png"/>
</a>
</li>
<li>
<p>
Select
<strong>
Add additional tag
</strong>
to add another tag.
</p>
<a href="/docs/latest/images/rc/tags-button-add-additional-tag.png" sdata-lightbox="/images/rc/tags-button-add-additional-tag.png">
<img alt="The Add additional tag button." src="/docs/latest/images/rc/tags-button-add-additional-tag.png" width="200px"/>
</a>
</li>
</ul>
<p>
Select
<strong>
Save tags
</strong>
to save your changes.
</p>
<a href="/docs/latest/images/rc/tags-button-save-tags.png" sdata-lightbox="/images/rc/tags-button-save-tags.png">
<img alt="The Save tags button." src="/docs/latest/images/rc/tags-button-save-tags.png" width="100px"/>
</a>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/databases/tag-database/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/operate/rc/changelog/2023/december-2023/.html | <section class="prose w-full py-12 max-w-none">
<h1>
Redis Cloud changelog (December 2023)
</h1>
<p class="text-lg -mt-5 mb-10">
New features, enhancements, and other changes added to Redis Cloud during December 2023.
</p>
<h2 id="new-features">
New features
</h2>
<h3 id="active-active-json-support">
Active-Active JSON support
</h3>
<p>
<a href="/docs/latest/operate/rc/databases/configuration/active-active-redis/">
Active-Active databases
</a>
on Redis Cloud now support the
<a href="/docs/latest/operate/oss_and_stack/stack-with-enterprise/json/">
JSON
</a>
data type.
</p>
<p>
See
<a href="/docs/latest/operate/rc/databases/create-database/create-active-active-database/">
Create an Active-Active subscription
</a>
to learn how to create an Active-Active subscription.
</p>
<h3 id="mutual-tls-enhancements">
Mutual TLS enhancements
</h3>
<p>
Databases that support
<a href="/docs/latest/operate/rc/security/database-security/tls-ssl/">
Transport layer security (TLS)
</a>
now support multiple client certificates for use with mutual TLS. This makes it easier to rotate client certificates outside of a maintenance window. In addition, you can now provide a client Certificate Authority chain to trust any leaf certificate it signed for more flexibility.
</p>
<p>
See
<a href="/docs/latest/operate/rc/security/database-security/tls-ssl/">
Transport layer security (TLS)
</a>
to learn how to enable TLS.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/operate/rc/changelog/2023/december-2023/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/phonetic_matching/.html | <section class="prose w-full py-12">
<h1>
Phonetic matching
</h1>
<p class="text-lg -mt-5 mb-10">
Details about phonetic matching capabilities
</p>
<p>
Phonetic matching, for example "Jon" vs. "John", allows searching for terms based on their pronunciation. This capability can be a useful tool when searching for names of people.
</p>
<p>
Phonetic matching is based on the use of a phonetic algorithm. A phonetic algorithm transforms the input term to an approximate representation of its pronunciation. This allows terms to be indexed and searched by their pronunciation.
</p>
<p>
As of v1.4, RediSearch provides phonetic matching of text fields specified with the
<code>
PHONETIC
</code>
attribute. This causes the terms in such fields to be indexed both by their textual value as well as their phonetic approximation.
</p>
<p>
Performing a search on
<code>
PHONETIC
</code>
fields will, by default, also return results for phonetically similar terms. This behavior can be controlled with the
<a href="/docs/latest/develop/interact/search-and-query/query/#query-attributes">
<code>
$phonetic
</code>
query attribute
</a>
.
</p>
<h2 id="phonetic-algorithms-support">
Phonetic algorithms support
</h2>
<p>
Redis Stack currently supports a single phonetic algorithm, the
<a href="https://en.wikipedia.org/wiki/Metaphone#Double_Metaphone">
Double Metaphone
</a>
(DM). It uses the implementation at the
<a href="https://github.com/slacy/double-metaphone">
slacy/double-metaphone GitHub site
</a>
, which provides general support for Latin languages.
</p>
<form class="text-sm w-full mt-24 pt-5 border-t border-t-redis-pen-700 border-opacity-50" id="page-feedback" name="page-feedback">
<input class="hidden" name="origin" value="https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/phonetic_matching/"/>
<div class="flex flex-row justify-between">
<div class="grid justify-center">
<span class="font-mono">
RATE THIS PAGE
</span>
<div class="star-rating">
<input id="5-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="5"/>
<label class="star" for="5-stars">
β
</label>
<input id="4-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="4"/>
<label class="star" for="4-stars">
β
</label>
<input id="3-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="3"/>
<label class="star" for="3-stars">
β
</label>
<input id="2-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="2"/>
<label class="star" for="2-stars">
β
</label>
<input id="1-stars" name="rating" onchange="document.querySelector('#feedback-form').classList.remove('hidden')" type="radio" value="1"/>
<label class="star" for="1-stars">
β
</label>
</div>
</div>
<a class="font-mono no-underline" href="#">
Back to top β
</a>
</div>
<div class="hidden" id="feedback-form">
<div class="grid gap-2">
<textarea class="p-2 mt-1 block w-full h-24 border border-opacity-50 border-redis-ink-900 rounded-md" name="comment" placeholder="Why did you choose this rating?" rows="3"></textarea>
<button class="font-mono button text-redis-ink-900 border border-solid border-transparent bg-redis-red-500 hover:bg-redis-red-600 focus:bg-red-600 focus:ring-red-600; w-min justify-self-end" type="submit">
Submit
</button>
</div>
</div>
</form>
<script>
document.addEventListener("DOMContentLoaded", function() {
const form = document.querySelector("#page-feedback");
form.addEventListener("submit", function(event) {
event.preventDefault();
var xhr = new XMLHttpRequest();
var url = "\/docusight\/api\/rate";
var params = new URLSearchParams(new FormData(form));
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const responseData = JSON.parse(xhr.responseText);
const responseMessage = responseData.response;
const newText = document.createTextNode(responseMessage);
form.parentNode.replaceChild(newText, form);
}
};
xhr.send(params);
});
});
</script>
</section>
|
Subsets and Splits