Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC-3967 Restructure sidebar #429

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion content/commands/scan/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Also note that this behavior is specific of [`SSCAN`]({{< relref "/commands/ssca

## Further reading

For more information about managing keys, please refer to the [The Redis Keyspace]({{< relref "/develop/use/keyspace" >}}) tutorial.
For more information about managing keys, please refer to [Keys and values]({{< relref "/develop/concepts/keys-values" >}}).

## Additional examples

Expand Down
22 changes: 22 additions & 0 deletions content/develop/concepts/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
description: Overview of the most important concepts in Redis
linkTitle: Understand Redis concepts
title: Understand Redis Concepts
hideListLinks: true
weight: 35
---

This section introduces concepts that are fundamental to using Redis:

- [Keys and values]({{< relref "/develop/concepts/keys-values" >}})
- [Data types]({{< relref "/develop/data-types" >}})
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,37 @@ description: 'Managing keys in Redis: Key expiration, scanning, altering and que
the key space

'
linkTitle: Keyspace
title: Keyspace
linkTitle: Keys and values
title: Keys and values
weight: 1
aliases: /develop/use/keyspace
---

Redis keys are binary safe; this means that you can use any binary sequence as a
key, from a string like "foo" to the content of a JPEG file.
The empty string is also a valid key.
Every data object that you store in a Redis database has its own unique
*key*. The key is a string that you pass to Redis commands to
retrieve the corresponding object or modify its data. The data object associated with a
particular key is known as the *value* and the two together are known as
as *key-value pair*.

A few other rules about keys:
## Content of keys

* Very long keys are not a good idea. For instance a key of 1024 bytes is a bad
A key is typically a textual name that has some meaning within your
data model. Unlike variable names in a programming language, Redis keys have few
restrictions on their format, so keys with whitespace or punctuation characters
are mostly fine (for example, "1st Attempt", or "% of price in $"). Redis doesn't
support namespaces or other categories for keys, so you must take care to avoid
name collisions. However, there is a convention for using the colon ":"
character to split keys into sections (for example, "person:1", "person:2",
"office:London", "office:NewYork:1"). You can use this as a simple way to collect
keys together into categories.

Although keys are usually textual, Redis actually implements *binary-safe* keys,
so you can use any sequence of bytes as a valid key, such as a JPEG file or
a struct value from your app. The empty string is also a valid key in Redis.

There are also a few other things to bear in mind about keys:

* Very long keys are not a good idea. For instance, a key of 1024 bytes is a bad
idea not only memory-wise, but also because the lookup of the key in the
dataset may require several costly key-comparisons. Even when the task at hand
is to match the existence of a large value, hashing it (for example
Expand All @@ -40,6 +59,49 @@ A few other rules about keys:
fields, as in "comment:4321:reply.to" or "comment:4321:reply-to".
* The maximum allowed key size is 512 MB.

### Hashtags

Redis uses [hashing](https://en.wikipedia.org/wiki/Hash_table) to retrieve the
value associated with a key in a highly efficient way. Hashing involves combining the
raw byte values from the key to produce an integer *index* number. The index is then
used to locate the *hash slot* where the value for the key is stored.

Normally, the whole key is used to calculate the hash index, but there are some
situations where you need to hash only a part of the key. You can select the
section of the key you want to hash using a pair of curly braces `{...}` to create
a *hashtag*. For example, the keys `person:1` and `person:2` produce different
hash indices but `{person}:1` and `{person}:2` produce the same index because
only the `person` hashtag section in the braces is used for the hash calculation.

A common use of hashtags is to allow
[multi-key operations]({{< relref "/operate/rs/databases/durability-ha/clustering" >}})
with a *clustered* database (see
[Database clustering]({{< relref "/operate/rs/databases/durability-ha/clustering#multikey-operations" >}})
for more information). Redis doesn't allow most multi-key operations in a clustered database
unless all the keys produce the same hash index. For example, the
[SINTER]({{< relref "/commands/sinter" >}})
command finds the [intersection](https://en.wikipedia.org/wiki/Intersection_(set_theory))
of two different [set]({{< relref "/develop/data-types/sets" >}}) values.
This means that the command

```bash
SINTER group:1 group:2
```

won't work with a clustered database but

```bash
SINTER {group}:1 {group}:2
```

will work because the hashtag ensures the two keys produce the same hash index.

Note that although hashtags are useful in certain cases, you shouldn't make
a habit of using them generally. If you have too many keys mapped to the same
hash slot then this will eventually harm the performance of your database.
See [Database clustering]({{< relref "/operate/rs/databases/durability-ha/clustering" >}})
for more information about how to use hashtags.

## Altering and querying the key space

There are commands that are not defined on particular types, but are useful
Expand Down Expand Up @@ -120,6 +182,7 @@ the [`PTTL`]({{< relref "/commands/pttl" >}}) commands, and the full list of [`S
## Navigating the keyspace

### Scan

To incrementally iterate over the keys in a Redis database in an efficient manner, you can use the [`SCAN`]({{< relref "/commands/scan" >}}) command.

Since [`SCAN`]({{< relref "/commands/scan" >}}) allows for incremental iteration, returning only a small number of elements per call, it can be used in production without the downside of commands like [`KEYS`]({{< relref "/commands/keys" >}}) or [`SMEMBERS`]({{< relref "/commands/smembers" >}}) that may block the server for a long time (even several seconds) when called against big collections of keys or elements.
Expand All @@ -139,7 +202,7 @@ This command is intended for debugging and special operations, such as changing
your keyspace layout.
Don't use [`KEYS`]({{< relref "/commands/keys" >}}) in your regular application code.
If you're looking for a way to find keys in a subset of your keyspace, consider
using [`SCAN`]({{< relref "/commands/scan" >}}) or [sets][tdts].
using [`SCAN`]({{< relref "/commands/scan" >}}) or [sets][{{< relref "/develop/data-types/sets" >}}].

[tdts]: /develop/data-types#sets

Expand Down
2 changes: 1 addition & 1 deletion content/develop/data-types/hashes.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ See the [complete list of hash commands]({{< relref "/commands/" >}}?group=hash)
## Field expiration

New in Redis Community Edition 7.4 is the ability to specify an expiration time or a time-to-live (TTL) value for individual hash fields.
This capability is comparable to [key expiration]({{< baseurl "/develop/use/keyspace" >}}#key-expiration") and includes a number of similar commands.
This capability is comparable to [key expiration]({{< relref "/develop/concepts/keys-values#key-expiration" >}}") and includes a number of similar commands.

Use the following commands to set either an exact expiration time or a TTL value for specific fields:

Expand Down
6 changes: 3 additions & 3 deletions content/develop/get-started/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ description: 'Redis quick start guides

'
hideListLinks: true
linkTitle: Quick starts
title: Quick starts
linkTitle: Quick start tutorials
title: Quick start tutorials
weight: 20
---

Expand All @@ -26,4 +26,4 @@ Redis can be used as a database, cache, streaming engine, message broker, and mo

Please select the guide that aligns best with your specific usage scenario.

You can find answers to frequently asked questions in the [FAQ]({{< relref "/develop/get-started/faq" >}}).
You can find answers to frequently asked questions in the [FAQ]({{< relref "/develop/quickstart/faq" >}}).
2 changes: 1 addition & 1 deletion content/develop/get-started/data-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ You can get a complete overview of available data types in this documentation si

## Scan the keyspace

Each item within Redis has a unique key. All items live within the Redis [keyspace]({{< relref "/develop/use/keyspace" >}}). You can scan the Redis keyspace via the [SCAN command]({{< relref "/commands/scan" >}}). Here is an example that scans for the first 100 keys that have the prefix `bike:`:
Each item within Redis has a unique key. All items live within the Redis [keyspace]({{< relref "/develop/concepts/keys-values" >}}). You can scan the Redis keyspace via the [SCAN command]({{< relref "/commands/scan" >}}). Here is an example that scans for the first 100 keys that have the prefix `bike:`:

```
SCAN 0 MATCH "bike:*" COUNT 100
Expand Down
30 changes: 30 additions & 0 deletions content/develop/quickstart/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
description: Get started quickly with Redis
linkTitle: Get started
title: Get started
hideListLinks: true
weight: 35
---

Use the pages in this section to start working with Redis right away.

The Quickstart tutorials provide a good way to see how Redis can
handle some common use cases:

- As a [data store]({{< relref "/develop/get-started/data-store" >}})
- As a [document database]({{< relref "/develop/get-started/document-database" >}})
- As a [vector database]({{< relref "/develop/get-started/vector-database" >}})
- For [Retrieval Augmented Generation (RAG)]({{< relref "/develop/get-started/rag" >}})

There is also an [FAQ]({{< relref "/develop/quickstart/faq" >}}) that answers
some of the most common questions users ask about Redis.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ description: 'Commonly asked questions when getting started with Redis
'
linkTitle: FAQ
title: Redis FAQ
aliases: /develop/get-started/faq
weight: 100
---
## How is Redis different from other key-value stores?
Expand Down
2 changes: 1 addition & 1 deletion content/operate/oss_and_stack/management/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ weight: 1

* Deploy Redis using the Linux operating system. Redis is also tested on OS X, and from time to time on FreeBSD and OpenBSD systems. However, Linux is where most of the stress testing is performed, and where most production deployments are run.

* Set the Linux kernel overcommit memory setting to 1. Add `vm.overcommit_memory = 1` to `/etc/sysctl.conf`. Then, reboot or run the command `sysctl vm.overcommit_memory=1` to activate the setting. See [FAQ: Background saving fails with a fork() error on Linux?]({{< baseurl >}}/develop/get-started/faq/#background-saving-fails-with-a-fork-error-on-linux) for details.
* Set the Linux kernel overcommit memory setting to 1. Add `vm.overcommit_memory = 1` to `/etc/sysctl.conf`. Then, reboot or run the command `sysctl vm.overcommit_memory=1` to activate the setting. See [FAQ: Background saving fails with a fork() error on Linux?]({{< baseurl >}}/develop/quickstart/faq/#background-saving-fails-with-a-fork-error-on-linux) for details.

* To ensure the Linux kernel feature Transparent Huge Pages does not impact Redis memory usage and latency, run the command: `echo never > /sys/kernel/mm/transparent_hugepage/enabled` to disable it. See [Latency Diagnosis - Latency induced by transparent huge pages]({{< baseurl >}}/operate/oss_and_stack/management/optimization/latency#latency-induced-by-transparent-huge-pages) for additional context.

Expand Down
Loading
Loading