Skip to content

Commit 3465c30

Browse files
DOC-5991 initial tree diagram and format now solid
1 parent ebb3e78 commit 3465c30

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

assets/css/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ section.prose {
9494
padding: 1rem;
9595
}
9696

97+
.prose pre.decision-tree-source {
98+
display: none;
99+
}
100+
97101
.prose pre > code {
98102
@apply bg-none font-monogeist;
99103
}

content/develop/data-types/compare-data-types.md

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -145,40 +145,17 @@ to manage multiple readers and ensure at-least-once delivery.
145145
## Choose a data type
146146

147147
The sections below explore the pros and cons of each data type for
148-
particular tasks.
148+
particular tasks. Note that you should regard
149+
the suggestions as "rules-of-thumb" rather than strict prescriptions, since
150+
there are potentially many subtle reasons to prefer one data type over another.
149151

150152
### Documents
151153

152154
You would normally store document data using the string, hash, or JSON
153155
types. JSON generally has the highest requirements for memory and processing,
154-
followed by hashes, and then strings. Use the considerations below as a guide to
156+
followed by hashes, and then strings. Use the decision tree below as a guide to
155157
choosing the best data type for your task.
156158

157-
1. Do you need nested data structures (fields and arrays) or geospatial
158-
index/query with Redis query engine?
159-
160-
If so, use **JSON** since it is the only type that supports these features.
161-
162-
2. Do you need to index/query using Redis query engine but can live without
163-
nested data structures and geospatial data?
164-
165-
If so, use **hashes** since they support indexing and querying with lower memory overhead and faster field access than JSON.
166-
167-
3. Do you need to set expiration times on individual pieces of data within
168-
the document?
169-
170-
If so, use **hashes** for efficient field-level access and expiration.
171-
172-
4. Do you need frequent access to individual data fields within the document?
173-
174-
If the data fields are simple integers or individual bits and you can
175-
easily refer to them by an integer index, use **strings** for efficient
176-
access and minimum memory overhead. Otherwise, use **hashes** for
177-
named fields and support for string and binary field values.
178-
179-
5. For other simple documents with arbitrary internal structure, use **strings**
180-
for simplicity and minimum memory overhead.
181-
182159
```decision-tree
183160
rootQuestion: root
184161
questions:
@@ -288,7 +265,7 @@ names matching the keys in the collection.
288265
need to store extra information for each key, consider using **hashes** with
289266
the keys as field names.
290267

291-
## Sequences
268+
### Sequences
292269

293270
You would normally store sequences of string or binary data using sorted sets,
294271
lists or streams. They each have advantages and disadvantages for particular purposes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{{- /* Render hook for decision tree code blocks */ -}}
2+
{{- /* Preserve YAML source for visual display and JavaScript parsing */ -}}
23
<pre class="decision-tree-source">{{ .Inner | htmlEscape | safeHTML }}</pre>
4+
5+
{{- /* Embed metadata as custom JSON for AI agents */ -}}
6+
{{- $metadata := dict "type" "decision-tree" -}}
7+
8+
{{ $jsonMetadata := $metadata | jsonify (dict "indent" " ") }}
9+
{{ printf "<script type=\"application/json\" data-redis-metadata=\"decision-tree\">\n%s\n</script>" $jsonMetadata | safeHTML }}
10+
311
{{ .Page.Store.Set "hasDecisionTree" true }}
412

0 commit comments

Comments
 (0)