Skip to content

Commit a370bbe

Browse files
enjoy-binbintheoboldalexoranagra
authored
Update outdated commands descriptions and cleanups in README (redis#11372)
Redis commands has been significantly refactored in 7.0. This PR updates the outdated README.md to reflect it. Based on redis#10864, doing some additional cleanups. Co-authored-by: theoboldalex <theoboldalex@gmail.com> Co-authored-by: Oran Agra <oran@redislabs.com>
1 parent 4c53bdc commit a370bbe

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

README.md

+26-23
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ When you update the source code with `git pull` or when code inside the
7575
dependencies tree is modified in any other way, make sure to use the following
7676
command in order to really clean everything and rebuild from scratch:
7777

78-
make distclean
78+
% make distclean
7979

80-
This will clean: jemalloc, lua, hiredis, linenoise.
80+
This will clean: jemalloc, lua, hiredis, linenoise and other dependencies.
8181

8282
Also if you force certain build options like 32bit target, no C compiler
8383
optimizations (for debugging purposes), and other similar build time options,
@@ -319,13 +319,17 @@ As you can see in the client structure above, arguments in a command
319319
are described as `robj` structures. The following is the full `robj`
320320
structure, which defines a *Redis object*:
321321

322-
typedef struct redisObject {
323-
unsigned type:4;
324-
unsigned encoding:4;
325-
unsigned lru:LRU_BITS; /* lru time (relative to server.lruclock) */
326-
int refcount;
327-
void *ptr;
328-
} robj;
322+
```c
323+
struct redisObject {
324+
unsigned type:4;
325+
unsigned encoding:4;
326+
unsigned lru:LRU_BITS; /* LRU time (relative to global lru_clock) or
327+
* LFU data (least significant 8 bits frequency
328+
* and most significant 16 bits access time). */
329+
int refcount;
330+
void *ptr;
331+
};
332+
```
329333

330334
Basically this structure can represent all the basic Redis data types like
331335
strings, lists, sets, sorted sets and so forth. The interesting thing is that
@@ -451,8 +455,9 @@ replicas, or to continue the replication after a disconnection.
451455

452456
Script
453457
---
454-
The script unit is compose of 3 units
455-
* `script.c` - integration of scripts with Redis (commands execution, set replication/resp, ..)
458+
459+
The script unit is composed of 3 units:
460+
* `script.c` - integration of scripts with Redis (commands execution, set replication/resp, ...)
456461
* `script_lua.c` - responsible to execute Lua code, uses script.c to interact with Redis from within the Lua code.
457462
* `function_lua.c` - contains the Lua engine implementation, uses script_lua.c to execute the Lua code.
458463
* `functions.c` - contains Redis Functions implementation (FUNCTION command), uses functions_lua.c if the function it wants to invoke needs the Lua engine.
@@ -476,24 +481,22 @@ Anatomy of a Redis command
476481

477482
All the Redis commands are defined in the following way:
478483

479-
void foobarCommand(client *c) {
480-
printf("%s",c->argv[1]->ptr); /* Do something with the argument. */
481-
addReply(c,shared.ok); /* Reply something to the client. */
482-
}
483-
484-
The command is then referenced inside `server.c` in the command table:
485-
486-
{"foobar",foobarCommand,2,"rtF",0,NULL,0,0,0,0,0},
484+
```c
485+
void foobarCommand(client *c) {
486+
printf("%s",c->argv[1]->ptr); /* Do something with the argument. */
487+
addReply(c,shared.ok); /* Reply something to the client. */
488+
}
489+
```
487490
488-
In the above example `2` is the number of arguments the command takes,
489-
while `"rtF"` are the command flags, as documented in the command table
490-
top comment inside `server.c`.
491+
The command function is referenced by a JSON file, together with its metadata, see `commands.c` described above for details.
492+
The command flags are documented in the comment above the `struct redisCommand` in `server.h`.
493+
For other details, please refer to the `COMMAND` command. https://redis.io/commands/command/
491494
492495
After the command operates in some way, it returns a reply to the client,
493496
usually using `addReply()` or a similar function defined inside `networking.c`.
494497
495498
There are tons of command implementations inside the Redis source code
496-
that can serve as examples of actual commands implementations. Writing
499+
that can serve as examples of actual commands implementations (e.g. pingCommand). Writing
497500
a few toy commands can be a good exercise to get familiar with the code base.
498501
499502
There are also many other files not described here, but it is useless to

0 commit comments

Comments
 (0)