Skip to content

Commit fdda190

Browse files
resolve merge conflicts
2 parents c1e00ac + 7aae395 commit fdda190

33 files changed

+663
-70
lines changed

course-definition.yml

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extensions:
8181
8282
Along the way you'll learn about commands like [XADD][xadd-command], [XRANGE][xrange-command] and more.
8383
84-
[redis-streams-data-type]: https://redis.io/docs/data-types/streams/
84+
[redis-streams-data-type]: https://redis.io/docs/latest/develop/data-types/streams/
8585
[xadd-command]: https://redis.io/commands/xadd/
8686
[xrange-command]: https://redis.io/commands/xrange/
8787
@@ -104,7 +104,7 @@ extensions:
104104
105105
Along the way you'll learn about how Redis's leader-follower replication works, the [PSYNC][redis-psync-command] command and more.
106106
107-
[redis-replication]: https://redis.io/docs/management/replication/
107+
[redis-replication]: https://redis.io/docs/latest/operate/oss_and_stack/management/replication/
108108
[redis-psync-command]: https://redis.io/commands/psync/
109109
110110
- slug: "persistence-rdb"
@@ -114,7 +114,7 @@ extensions:
114114
115115
Along the way you'll learn about Redis's [RDB file format][rdb-file-format] and more.
116116
117-
[redis-persistence]: https://redis.io/docs/manual/persistence/
117+
[redis-persistence]: https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/
118118
[rdb-file-format]: https://github.com/sripathikrishnan/redis-rdb-tools/blob/548b11ec3c81a603f5b321228d07a61a0b940159/docs/RDB_File_Format.textile
119119
120120
- slug: "pub-sub"
@@ -127,6 +127,17 @@ extensions:
127127
[redis-pub-sub]: https://redis.io/docs/latest/develop/pubsub/
128128
[subscribe-command]: https://redis.io/docs/latest/commands/subscribe/
129129
[publish-command]: https://redis.io/docs/latest/commands/publish/
130+
131+
- slug: "sorted-sets"
132+
name: "Sorted Sets"
133+
description_markdown : |-
134+
In this challenge extension you'll add support for [Sorted Sets (zsets)][redis-zset] to your Redis implementation.
135+
136+
Along the way, you'll learn commands like [ZADD][zadd-command], [ZRANGE][zrange-command], and more.
137+
138+
[redis-zset]: https://redis.io/docs/latest/develop/data-types/sorted-sets/
139+
[zadd-command]: https://redis.io/docs/latest/commands/zadd/
140+
[zrange-command]: https://redis.io/docs/latest/commands/zrange/
130141
131142
- slug: "geospatial"
132143
name: "Geospatial Commands"
@@ -139,7 +150,6 @@ extensions:
139150
[geoadd-command]: https://redis.io/docs/latest/commands/geoadd/
140151
[geosearch-command]: https://redis.io/docs/latest/commands/geosearch/
141152
142-
143153
stages:
144154
- slug: "jm1"
145155
concept_slugs:
@@ -422,7 +432,7 @@ stages:
422432
name: "Create a stream"
423433
difficulty: medium
424434
marketing_md: |
425-
In this stage, you'll add support for creating a [Redis stream](https://redis.io/docs/data-types/streams/) using the `XADD` command.
435+
In this stage, you'll add support for creating a [Redis stream](https://redis.io/docs/latest/develop/data-types/streams/) using the `XADD` command.
426436
427437
- slug: "hq8"
428438
primary_extension_slug: "streams"
@@ -690,6 +700,63 @@ stages:
690700
difficulty: medium
691701
marketing_md: In this stage, you'll add support for the `UNSUBSCRIBE command`, which is used to unsubscribe from a channel.
692702

703+
# Sorted Sets
704+
- slug: "ct1"
705+
primary_extension_slug: "sorted-sets"
706+
name: "Create a sorted set"
707+
difficulty: easy
708+
marketing_md: |
709+
In this stage, you'll add support for creating a [sorted set](https://redis.io/docs/latest/develop/data-types/sorted-sets/) using the `ZADD` command.
710+
711+
- slug: "hf1"
712+
primary_extension_slug: "sorted-sets"
713+
name: "Add members"
714+
difficulty: medium
715+
marketing_md: |
716+
In this stage, you'll add support for adding elements to an existing sorted set.
717+
718+
- slug: "lg6"
719+
primary_extension_slug: "sorted-sets"
720+
name: "Retrieve member rank"
721+
difficulty: medium
722+
marketing_md: |
723+
In this stage, you'll add support for retrieving the rank of a sorted set member using the `ZRANK` command.
724+
725+
- slug: "ic1"
726+
primary_extension_slug: "sorted-sets"
727+
name: "List sorted set members"
728+
difficulty: easy
729+
marketing_md: |
730+
In this stage, you'll add support for listing the members of a sorted set using the `ZRANGE` command.
731+
732+
- slug: "bj4"
733+
primary_extension_slug: "sorted-sets"
734+
name: "ZRANGE with negative indexes"
735+
difficulty: easy
736+
marketing_md: |
737+
In this stage, you'll add support for negative indexes for the `ZRANGE` command.
738+
739+
- slug: "kn4"
740+
primary_extension_slug: "sorted-sets"
741+
name: "Count sorted set members"
742+
difficulty: easy
743+
marketing_md: |
744+
In this stage, you'll add support for counting the number of members in a sorted set using the `ZCARD` command.
745+
746+
- slug: "gd7"
747+
primary_extension_slug: "sorted-sets"
748+
name: "Retrieve member score"
749+
difficulty: medium
750+
marketing_md: |
751+
In this stage, you'll add support for retrieving the score of a sorted set member using the `ZSCORE` command.
752+
753+
- slug: "sq7"
754+
primary_extension_slug: "sorted-sets"
755+
name: "Remove a member"
756+
difficulty: easy
757+
marketing_md: |
758+
In this stage, you'll add support for removing a member of a sorted set using the `ZREM` command.
759+
693760
# Geospatial Commands
694761
- slug: "zt4"
695762
primary_extension_slug: "geospatial"

dockerfiles/ocaml-5.3.Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1.7-labs
2-
FROM ocaml/opam:alpine-3.21-ocaml-5.3
2+
FROM ocaml/opam:debian-11-ocaml-5.3
33

44
# The image uses opam as the user, so let's set OPAMROOT to re-use whatever is already built
55
ENV OPAMROOT /home/opam/.opam
@@ -24,6 +24,3 @@ COPY --exclude=.git --exclude=README.md . /app
2424

2525
# Cache dependencies
2626
RUN opam install . --yes
27-
28-
# This runs dune build
29-
RUN .codecrafters/compile.sh

stage_descriptions/base-02-rg2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Commands and responses are both encoded using the [Redis protocol](https://redis
55

66
[PING](https://redis.io/commands/ping/) is one of the simplest Redis commands. It's used to check whether a Redis server is healthy.
77

8-
The response for the `PING` command is `+PONG\r\n`. This is the string "PONG" encoded using the [Redis protocol](https://redis.io/docs/reference/protocol-spec/).
8+
The response for the `PING` command is `+PONG\r\n`. This is the string "PONG" encoded using the [Redis protocol](https://redis.io/docs/latest/develop/reference/protocol-spec).
99

1010
In this stage, we'll cut corners by ignoring client input and hardcoding `+PONG\r\n` as a response. We'll learn to parse client input in later stages.
1111

@@ -23,7 +23,7 @@ It'll then send a `PING` command to your server and expect a `+PONG\r\n` respons
2323
$ redis-cli PING
2424
```
2525

26-
Your server should respond with `+PONG\r\n`, which is "PONG" encoded as a [RESP simple string](https://redis.io/docs/reference/protocol-spec/#resp-simple-strings).
26+
Your server should respond with `+PONG\r\n`, which is "PONG" encoded as a [RESP simple string](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-strings).
2727

2828
### Notes
2929

stage_descriptions/base-05-qq0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ It'll then send an `ECHO` command with an argument to your server:
2424
$ redis-cli ECHO hey
2525
```
2626

27-
The tester will expect to receive `$3\r\nhey\r\n` as a response (that's the string `hey` encoded as a [RESP bulk string](https://redis.io/docs/reference/protocol-spec/#bulk-strings).
27+
The tester will expect to receive `$3\r\nhey\r\n` as a response (that's the string `hey` encoded as a [RESP bulk string](https://redis.io/docs/latest/develop/reference/protocol-spec/#bulk-strings).
2828

2929
### Notes
3030

3131
- We suggest that you implement a proper Redis protocol parser in this stage. It'll come in handy in later stages.
3232
- Redis command names are case-insensitive, so `ECHO`, `echo` and `EcHo` are all valid commands.
3333
- The tester will send a random string as an argument to the `ECHO` command, so you won't be able to hardcode the response to pass this stage.
3434
- The exact bytes your program will receive won't be just `ECHO hey`, you'll receive something like this: `*2\r\n$4\r\nECHO\r\n$3\r\nhey\r\n`. That's
35-
`["ECHO", "hey"]` encoded using the [Redis protocol](https://redis.io/docs/reference/protocol-spec/).
36-
- You can read more about how "commands" are handled in the Redis protocol [here](https://redis.io/docs/reference/protocol-spec/#sending-commands-to-a-redis-server).
35+
`["ECHO", "hey"]` encoded using the [Redis protocol](https://redis.io/docs/latest/develop/reference/protocol-spec/).
36+
- You can read more about how "commands" are handled in the Redis protocol [here](https://redis.io/docs/latest/develop/reference/protocol-spec/#sending-commands-to-a-redis-server).

stage_descriptions/base-06-la7.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ It'll then send a `SET` command to your server:
2727
$ redis-cli SET foo bar
2828
```
2929

30-
The tester will expect to receive `+OK\r\n` as a response (that's the string `OK` encoded as a [RESP simple string](https://redis.io/docs/reference/protocol-spec/#resp-simple-strings)).
30+
The tester will expect to receive `+OK\r\n` as a response (that's the string `OK` encoded as a [RESP simple string](https://redis.io/docs/latest/develop/reference/protocol-spec/#simple-strings)).
3131

3232
This command will be followed by a `GET` command:
3333

3434
```bash
3535
$ redis-cli GET foo
3636
```
3737

38-
The tester will expect to receive `$3\r\nbar\r\n` as a response (that's the string `bar` encoded as a [RESP bulk string](https://redis.io/docs/reference/protocol-spec/#bulk-strings).
38+
The tester will expect to receive `$3\r\nbar\r\n` as a response (that's the string `bar` encoded as a [RESP bulk string](https://redis.io/docs/latest/develop/reference/protocol-spec/#bulk-strings).
3939

4040
### Notes
4141

stage_descriptions/lists-04-sf6.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Here are some additional notes on how the LRANGE command behaves with different
2727

2828
- If the list does not exist, an empty array is returned
2929
- If the start index is greater than or equal to the list's length, an empty array is returned.
30-
- If the stop index is greater than the list's length, the stop index is treated as the last element.
30+
- If the stop index is greater than or equal to the list's length, the stop index is treated as the last element.
3131
- If the start index is greater than the stop index, the result is an empty array.
3232

3333
### Tests

stage_descriptions/lists-07-fv6.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ The tester will then send a `LLEN` command specifying the list that was just cre
3333

3434
```bash
3535
> LLEN list_key
36-
# Expect: list_length (RESP Encoded Integer)
36+
# Expect: list_length (RESP Encoded Integer)
3737
```
3838

3939
It will expect the response to be length of the list encoded as a RESP integer.
4040

4141
It will also verify the response of `LLEN` command for a non-existent list.
4242

4343
```bash
44-
> LLEN non_existent_list_key
44+
> LLEN missing_list_key
4545
# Expect: (integer) 0
4646
```
4747

48-
The tester expects 0, which is RESP Encoded as `:0\r\n `.
48+
The tester expects 0, which is RESP Encoded as `:0\r\n `.

stage_descriptions/lists-11-xj7.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ It will then send a BLPOP command with a non-zero timeout:
1212

1313
```bash
1414
$ redis-cli BLPOP list_key 0.1
15-
# (Blocks)
15+
# (Blocks for 0.1 seconds)
1616
```
1717

1818
After the timeout expires, the tester will expect to receive a null bulk string (`$-1\r\n`) as the response.

stage_descriptions/persistence-rdb-01-zg5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Welcome to the RDB Persistence Extension! In this extension, you'll add support for reading [RDB files](https://redis.io/docs/management/persistence/) (Redis Database files).
1+
Welcome to the RDB Persistence Extension! In this extension, you'll add support for reading [RDB files](https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/) (Redis Database files).
22

33
In this stage, you'll add support for two configuration parameters related to RDB persistence, as well as the [CONFIG GET](https://redis.io/docs/latest/commands/config-get/) command.
44

stage_descriptions/persistence-rdb-02-jz6.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,33 @@ FF /* Indicates that the file is ending,
103103
89 3b b7 4e f8 0f 77 19 // An 8-byte CRC64 checksum of the entire file.
104104
```
105105

106-
#### Size encoding
106+
#### Length encoding
107107

108-
Size-encoded values specify the size of something. Here are some examples:
109-
- The database indexes and hash table sizes are size encoded.
110-
- String encoding begins with a size-encoded value that specifies the number of characters in the string.
111-
- List encoding begins with a size-encoded value that specifies the number of elements in the list.
108+
Length-encoded values specify the length or size of something. Here are some examples:
109+
- The database indexes and hash table sizes are length encoded.
110+
- String encoding begins with a length-encoded value that specifies the number of characters in the string.
111+
- List encoding begins with a length-encoded value that specifies the number of elements in the list.
112112

113-
The first (most significant) two bits of a size-encoded value indicate how the value should be parsed. Here's a guide (bits are shown in both hexadecimal and binary):
113+
The first (most significant) two bits of a length-encoded value indicate how the value should be parsed. Here's a guide (bits are shown in both hexadecimal and binary):
114114
```
115115
/* If the first two bits are 0b00:
116-
The size is the remaining 6 bits of the byte.
117-
In this example, the size is 10: */
116+
The length is the remaining 6 bits of the byte.
117+
In this example, the length is 10: */
118118
0A
119119
00001010
120120
121121
/* If the first two bits are 0b01:
122-
The size is the next 14 bits
122+
The length is the next 14 bits
123123
(remaining 6 bits in the first byte, combined with the next byte),
124124
in big-endian (read left-to-right).
125-
In this example, the size is 700: */
125+
In this example, the length is 700: */
126126
42 BC
127127
01000010 10111100
128128
129129
/* If the first two bits are 0b10:
130130
Ignore the remaining 6 bits of the first byte.
131-
The size is the next 4 bytes, in big-endian (read left-to-right).
132-
In this example, the size is 17000: */
131+
The length is the next 4 bytes, in big-endian (read left-to-right).
132+
In this example, the length is 17000: */
133133
80 00 00 42 68
134134
10000000 00000000 00000000 01000010 01101000
135135

0 commit comments

Comments
 (0)