Skip to content

Commit 3163db3

Browse files
committed
cheat sheet CLI draft 1
1 parent 8dcd643 commit 3163db3

File tree

15 files changed

+1501
-1
lines changed

15 files changed

+1501
-1
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
id: index-quick-start-cheat-sheet
3+
title: Redis Commands Cheat sheet
4+
sidebar_label: Cheat sheet
5+
slug: /howtos/quick-start/cheat-sheet
6+
authors: [prasan, will]
7+
---
8+
9+
import Authors from '@site/src/theme/Authors';
10+
11+
import CheatSheetConnect from './connect.mdx';
12+
import CheatSheetStrings from './strings.mdx';
13+
import CheatSheetGeneric from './generic.mdx';
14+
import CheatSheetHashes from './hashes.mdx';
15+
import CheatSheetSets from './sets.mdx';
16+
import CheatSheetSortedSets from './sorted-sets.mdx';
17+
import CheatSheetLists from './lists.mdx';
18+
import CheatSheetStreams from './streams.mdx';
19+
20+
import CheatSheetJSON from './json.mdx';
21+
import CheatSheetSearchAndQuery from './search-and-query.mdx';
22+
import CheatSheetTriggersAndFunctions from './triggers-and-functions.mdx';
23+
24+
<Authors frontMatter={frontMatter} />
25+
26+
## Connect
27+
28+
<CheatSheetConnect />
29+
30+
:::note
31+
To setup Redis either locally or in the cloud, refer to the [<u>tutorial</u>](/howtos/quick-start#setup-redis)
32+
:::
33+
34+
## Strings/Numbers
35+
36+
<CheatSheetStrings />
37+
38+
## Generic
39+
40+
<CheatSheetGeneric />
41+
42+
## Hashes
43+
44+
<CheatSheetHashes />
45+
46+
## Sets
47+
48+
<CheatSheetSets />
49+
50+
## Sorted sets
51+
52+
<CheatSheetSortedSets />
53+
54+
## Lists
55+
56+
<CheatSheetLists />
57+
58+
## Streams
59+
60+
<CheatSheetStreams />
61+
62+
### &nbsp;
63+
64+
<hr />
65+
66+
:::info Redis stack commands
67+
68+
[<u>Redis stack</u>](https://redis.io/docs/about/about-stack/) extends the core features
69+
of Redis OSS like querying across hashes and JSON documents, time series data support,
70+
full-text search ..etc
71+
72+
:::
73+
74+
## JSON
75+
76+
<CheatSheetJSON />
77+
78+
## Search and Query
79+
80+
<CheatSheetSearchAndQuery />
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
4+
<Tabs
5+
defaultValue="CLI"
6+
groupId="REDIS_CHEAT_SHEET"
7+
values={[
8+
{label: 'CLI', value: 'CLI'},
9+
{label: 'RedisInsight', value: 'REDIS_INSIGHT'},
10+
{label: 'NodeRedis', value: 'NODE_JS'},
11+
]}>
12+
13+
<TabItem value="CLI">
14+
15+
```sh
16+
# Syntax
17+
redis-cli -u redis://host:port
18+
redis-cli -u redis://username:password@host:port
19+
20+
# Examples
21+
redis-cli
22+
redis-cli -u redis://localhost:6379
23+
redis-cli -u redis://myuser:mypassword@localhost:6379
24+
25+
# If you run Redis through Docker
26+
docker exec -it <container-id-or-name> redis-cli
27+
28+
```
29+
30+
</TabItem>
31+
32+
<TabItem value="REDIS_INSIGHT">
33+
34+
Download <u>[RedisInsight](https://redis.com/redis-enterprise/redis-insight/)</u> to visually explore your Redis data or to engage with raw Redis commands in the workbench. Dive deeper into RedisInsight with these <u>[tutorials](/explore/redisinsight/)</u>.
35+
36+
![redis-insight-connect](./images/redis-insight-connect.png)
37+
38+
</TabItem>
39+
40+
<TabItem value="NODE_JS">
41+
42+
</TabItem>
43+
44+
</Tabs>
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
4+
<Tabs
5+
defaultValue="CLI"
6+
groupId="REDIS_CHEAT_SHEET"
7+
values={[
8+
{label: 'CLI', value: 'CLI'},
9+
{label: 'NodeRedis', value: 'NODE_JS'},
10+
]}>
11+
12+
<TabItem value="CLI">
13+
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>
18+
<strong>Command</strong>
19+
</td>
20+
<td>
21+
<strong>Syntax</strong>
22+
</td>
23+
<td>
24+
<strong>Example</strong>
25+
</td>
26+
<td>
27+
<strong>Output</strong>
28+
</td>
29+
</tr>
30+
<tr>
31+
<td>KEYS</td>
32+
<td>KEYS pattern</td>
33+
<td>
34+
<pre>
35+
<code>{`
36+
KEYS *name
37+
`}</code>
38+
</pre>
39+
</td>
40+
<td>["firstname", "lastname"]</td>
41+
</tr>
42+
<tr>
43+
<td colspan="4">
44+
<em>Description:</em> Returns all keys matching pattern.
45+
<em>Time Complexity:</em> O(N)
46+
</td>
47+
</tr>
48+
<tr>
49+
<td>EXISTS</td>
50+
<td>EXISTS key [key ...]</td>
51+
<td>
52+
<pre>
53+
<code>{`
54+
EXISTS mykey
55+
`}</code>
56+
</pre>
57+
</td>
58+
<td>(integer) 1</td>
59+
</tr>
60+
<tr>
61+
<td colspan="4">
62+
<em>Description:</em> Checks if one or more keys exist.
63+
<em>Time Complexity:</em> O(N)
64+
</td>
65+
</tr>
66+
<tr>
67+
<td>EXPIRE</td>
68+
<td>EXPIRE key seconds</td>
69+
<td>
70+
<pre>
71+
<code>{`
72+
EXPIRE mykey 120
73+
`}</code>
74+
</pre>
75+
</td>
76+
<td>(integer) 1</td>
77+
</tr>
78+
<tr>
79+
<td colspan="4">
80+
<em>Description:</em> Set a timeout on a key.After the timeout has
81+
expired, the key will automatically be deleted.<em>Time Complexity:</em>
82+
O(1)
83+
</td>
84+
</tr>
85+
<tr>
86+
<td>PERSIST</td>
87+
<td>PERSIST key</td>
88+
<td>
89+
<pre>
90+
<code>{`
91+
PERSIST mykey
92+
`}</code>
93+
</pre>
94+
</td>
95+
<td>(integer) 1</td>
96+
</tr>
97+
<tr>
98+
<td colspan="4">
99+
<em>Description:</em> Removes the expiration from a key.
100+
<em>Time Complexity:</em>
101+
O(1)
102+
</td>
103+
</tr>
104+
<tr>
105+
<td>TTL</td>
106+
<td>TTL key</td>
107+
<td>
108+
<pre>
109+
<code>{`
110+
TTL mykey
111+
`}</code>
112+
</pre>
113+
</td>
114+
<td>(integer) 113</td>
115+
</tr>
116+
<tr>
117+
<td colspan="4">
118+
<em>Description:</em> Returns the remaining time to live of a key that
119+
has a timeout.<em>Time Complexity:</em> O(1)
120+
</td>
121+
</tr>
122+
<tr>
123+
<td>SCAN</td>
124+
<td>SCAN cursor [MATCH pattern] [COUNT count]</td>
125+
<td>
126+
<pre>
127+
<code>{`
128+
SCAN 0 MATCH my* COUNT 2
129+
`}</code>
130+
</pre>
131+
</td>
132+
<td>1) "0" 2) 1) "mykey" 2) "myotherkey"</td>
133+
</tr>
134+
<tr>
135+
<td>DEL</td>
136+
<td>DEL key [key ...]</td>
137+
<td>
138+
<pre>
139+
<code>{`
140+
DEL mykey
141+
`}</code>
142+
</pre>
143+
</td>
144+
<td>(integer) 1</td>
145+
</tr>
146+
<tr>
147+
<td colspan="4">
148+
<em>Description:</em> Removes the specified keys.
149+
<em>Time Complexity:</em> O(N)
150+
</td>
151+
</tr>
152+
<tr>
153+
<td colspan="4">
154+
<em>Description:</em> Iterates the set of keys in the currently selected
155+
Redis database.<em>Time Complexity:</em> O(1) for every call. O(N) for a
156+
complete iteration.
157+
</td>
158+
</tr>
159+
<tr>
160+
<td>INFO</td>
161+
<td>INFO [section]</td>
162+
<td>
163+
<pre>
164+
<code>{`
165+
INFO server
166+
INFO keyspace
167+
`}</code>
168+
</pre>
169+
</td>
170+
<td>
171+
# Server
172+
<br />
173+
redis_version:6.2.5
174+
<br />
175+
redis_git_sha1:00000000
176+
<br />
177+
redis_build_id:9893b2a-dirty
178+
<br />
179+
redis_mode:standalone
180+
<br />
181+
os:Linux 5.4.72-microsoft-standard-WSL2 x86_64
182+
<br />
183+
arch_bits:64
184+
<br />
185+
... <br /># Keyspace db0:keys=2,expires=0,avg_ttl=0
186+
</td>
187+
</tr>
188+
<tr>
189+
<td colspan="4">
190+
<em>Description:</em>
191+
Returns information and statistics about the server, with the following sections:
192+
server, clients, memory, persistence, stats, replication, cpu, commandstats,
193+
latencystats, sentinel, cluster, modules, keyspace, errorstats.<em>
194+
Time Complexity:
195+
</em> O(1)
196+
</td>
197+
</tr>
198+
</tbody>
199+
</table>
200+
201+
</TabItem>
202+
203+
<TabItem value="NODE_JS">
204+
205+
</TabItem>
206+
207+
</Tabs>

0 commit comments

Comments
 (0)