Skip to content

Commit 7f52d5c

Browse files
authored
update commands.json and module docs with 7.2 RC2 (redis#2411)
includes some minor edits for commands.json arguments, and a few new module APIs
1 parent a43b9ab commit 7f52d5c

File tree

2 files changed

+159
-44
lines changed

2 files changed

+159
-44
lines changed

commands.json

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3107,7 +3107,7 @@
31073107
]
31083108
},
31093109
"COMMAND DOCS": {
3110-
"summary": "Returns documentary information about a command.",
3110+
"summary": "Returns documentary information about one, multiple or all commands.",
31113111
"since": "7.0.0",
31123112
"group": "server",
31133113
"complexity": "O(N) where N is the number of commands to look up",
@@ -5378,20 +5378,25 @@
53785378
]
53795379
},
53805380
{
5381-
"name": "storekey",
5382-
"type": "key",
5383-
"display_text": "key",
5384-
"key_spec_index": 1,
5385-
"token": "STORE",
5386-
"optional": true
5387-
},
5388-
{
5389-
"name": "storedistkey",
5390-
"type": "key",
5391-
"display_text": "key",
5392-
"key_spec_index": 2,
5393-
"token": "STOREDIST",
5394-
"optional": true
5381+
"name": "store",
5382+
"type": "oneof",
5383+
"optional": true,
5384+
"arguments": [
5385+
{
5386+
"name": "storekey",
5387+
"type": "key",
5388+
"display_text": "key",
5389+
"key_spec_index": 1,
5390+
"token": "STORE"
5391+
},
5392+
{
5393+
"name": "storedistkey",
5394+
"type": "key",
5395+
"display_text": "key",
5396+
"key_spec_index": 2,
5397+
"token": "STOREDIST"
5398+
}
5399+
]
53955400
}
53965401
],
53975402
"command_flags": [
@@ -5588,20 +5593,25 @@
55885593
]
55895594
},
55905595
{
5591-
"name": "storekey",
5592-
"type": "key",
5593-
"display_text": "key",
5594-
"key_spec_index": 1,
5595-
"token": "STORE",
5596-
"optional": true
5597-
},
5598-
{
5599-
"name": "storedistkey",
5600-
"type": "key",
5601-
"display_text": "key",
5602-
"key_spec_index": 2,
5603-
"token": "STOREDIST",
5604-
"optional": true
5596+
"name": "store",
5597+
"type": "oneof",
5598+
"optional": true,
5599+
"arguments": [
5600+
{
5601+
"name": "storekey",
5602+
"type": "key",
5603+
"display_text": "key",
5604+
"key_spec_index": 1,
5605+
"token": "STORE"
5606+
},
5607+
{
5608+
"name": "storedistkey",
5609+
"type": "key",
5610+
"display_text": "key",
5611+
"key_spec_index": 2,
5612+
"token": "STOREDIST"
5613+
}
5614+
]
56055615
}
56065616
],
56075617
"command_flags": [
@@ -15582,7 +15592,7 @@
1558215592
]
1558315593
},
1558415594
"XREADGROUP": {
15585-
"summary": "Returns new or historical messages from a stream for a consumer in agroup. Blocks until a message is available otherwise.",
15595+
"summary": "Returns new or historical messages from a stream for a consumer in a group. Blocks until a message is available otherwise.",
1558615596
"since": "5.0.0",
1558715597
"group": "stream",
1558815598
"complexity": "For each stream mentioned: O(M) with M being the number of elements returned. If M is constant (e.g. always asking for the first 10 elements with COUNT), you can consider it O(1). On the other side when XREADGROUP blocks, XADD will pay the O(N) time in order to serve the N clients blocked on the stream getting new data.",

docs/reference/modules/modules-api-ref.md

Lines changed: 119 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ aliases:
5050
* [Module fork API](#section-module-fork-api)
5151
* [Server hooks implementation](#section-server-hooks-implementation)
5252
* [Module Configurations API](#section-module-configurations-api)
53+
* [RDB load/save API](#section-rdb-load-save-api)
5354
* [Key eviction API](#section-key-eviction-api)
5455
* [Miscellaneous APIs](#section-miscellaneous-apis)
5556
* [Defrag API](#section-defrag-api)
@@ -802,7 +803,7 @@ Return counter of micro-seconds relative to an arbitrary point in time.
802803

803804
### `RedisModule_Microseconds`
804805

805-
ustime_t RedisModule_Microseconds();
806+
ustime_t RedisModule_Microseconds(void);
806807

807808
**Available since:** unreleased
808809

@@ -812,7 +813,7 @@ Return the current UNIX time in microseconds
812813

813814
### `RedisModule_CachedMicroseconds`
814815

815-
ustime_t RedisModule_CachedMicroseconds();
816+
ustime_t RedisModule_CachedMicroseconds(void);
816817

817818
**Available since:** unreleased
818819

@@ -1413,6 +1414,30 @@ and not just:
14131414

14141415
The function always returns `REDISMODULE_OK`.
14151416

1417+
<span id="RedisModule_ReplyWithErrorFormat"></span>
1418+
1419+
### `RedisModule_ReplyWithErrorFormat`
1420+
1421+
int RedisModule_ReplyWithErrorFormat(RedisModuleCtx *ctx,
1422+
const char *fmt,
1423+
...);
1424+
1425+
**Available since:** unreleased
1426+
1427+
Reply with the error create from a printf format and arguments.
1428+
1429+
If the error code is already passed in the string 'fmt', the error
1430+
code provided is used, otherwise the string "-ERR " for the generic
1431+
error code is automatically added.
1432+
1433+
The usage is, for example:
1434+
1435+
RedisModule_ReplyWithErrorFormat(ctx, "An error: %s", "foo");
1436+
1437+
RedisModule_ReplyWithErrorFormat(ctx, "-WRONGTYPE Wrong Type: %s", "foo");
1438+
1439+
The function always returns `REDISMODULE_OK`.
1440+
14161441
<span id="RedisModule_ReplyWithSimpleString"></span>
14171442

14181443
### `RedisModule_ReplyWithSimpleString`
@@ -2113,7 +2138,7 @@ Available flags and their meaning:
21132138

21142139
### `RedisModule_AvoidReplicaTraffic`
21152140

2116-
int RedisModule_AvoidReplicaTraffic();
2141+
int RedisModule_AvoidReplicaTraffic(void);
21172142

21182143
**Available since:** 6.0.0
21192144

@@ -2206,7 +2231,7 @@ Extra flags that can be pass to the API under the mode argument:
22062231

22072232
### `RedisModule_GetOpenKeyModesAll`
22082233

2209-
int RedisModule_GetOpenKeyModesAll();
2234+
int RedisModule_GetOpenKeyModesAll(void);
22102235

22112236
**Available since:** unreleased
22122237

@@ -4950,7 +4975,7 @@ Moreover, the fact that the notification is executed synchronously means
49504975
that the notification code will be executed in the middle on Redis logic
49514976
(commands logic, eviction, expire). Changing the key space while the logic
49524977
runs is dangerous and discouraged. In order to react to key space events with
4953-
write actions, please refer to `RedisModule_AddPostExecutionUnitJob`.
4978+
write actions, please refer to [`RedisModule_AddPostNotificationJob`](#RedisModule_AddPostNotificationJob).
49544979

49554980
See [https://redis.io/topics/notifications](https://redis.io/topics/notifications) for more information.
49564981

@@ -4984,7 +5009,7 @@ and so Redis will make no attempt to protect the module from infinite loops.
49845009

49855010
### `RedisModule_GetNotifyKeyspaceEvents`
49865011

4987-
int RedisModule_GetNotifyKeyspaceEvents();
5012+
int RedisModule_GetNotifyKeyspaceEvents(void);
49885013

49895014
**Available since:** 6.0.0
49905015

@@ -6295,7 +6320,7 @@ command should return an error.
62956320

62966321
Here is an example:
62976322

6298-
int ... myCommandImplementation() {
6323+
int ... myCommandImplementation(void) {
62996324
if (getExternalAPIs() == 0) {
63006325
reply with an error here if we cannot have the APIs
63016326
}
@@ -6507,7 +6532,7 @@ it does not include the allocation size of the keys and values.
65076532

65086533
### `RedisModule_GetUsedMemoryRatio`
65096534

6510-
float RedisModule_GetUsedMemoryRatio();
6535+
float RedisModule_GetUsedMemoryRatio(void);
65116536

65126537
**Available since:** 6.0.0
65136538

@@ -6527,7 +6552,7 @@ currently used, relative to the Redis "maxmemory" configuration.
65276552

65286553
### `RedisModule_ScanCursorCreate`
65296554

6530-
RedisModuleScanCursor *RedisModule_ScanCursorCreate();
6555+
RedisModuleScanCursor *RedisModule_ScanCursorCreate(void);
65316556

65326557
**Available since:** 6.0.0
65336558

@@ -7255,6 +7280,81 @@ This will return `REDISMODULE_ERR` if it is called outside `RedisModule_OnLoad`.
72557280
This API needs to be called when configurations are provided in either `MODULE LOADEX`
72567281
or provided as startup arguments.
72577282

7283+
<span id="section-rdb-load-save-api"></span>
7284+
7285+
## RDB load/save API
7286+
7287+
<span id="RedisModule_RdbStreamCreateFromFile"></span>
7288+
7289+
### `RedisModule_RdbStreamCreateFromFile`
7290+
7291+
RedisModuleRdbStream *RedisModule_RdbStreamCreateFromFile(const char *filename);
7292+
7293+
**Available since:** unreleased
7294+
7295+
Create a stream object to save/load RDB to/from a file.
7296+
7297+
This function returns a pointer to `RedisModuleRdbStream` which is owned
7298+
by the caller. It requires a call to [`RedisModule_RdbStreamFree()`](#RedisModule_RdbStreamFree) to free
7299+
the object.
7300+
7301+
<span id="RedisModule_RdbStreamFree"></span>
7302+
7303+
### `RedisModule_RdbStreamFree`
7304+
7305+
void RedisModule_RdbStreamFree(RedisModuleRdbStream *stream);
7306+
7307+
**Available since:** unreleased
7308+
7309+
Release an RDB stream object.
7310+
7311+
<span id="RedisModule_RdbLoad"></span>
7312+
7313+
### `RedisModule_RdbLoad`
7314+
7315+
int RedisModule_RdbLoad(RedisModuleCtx *ctx,
7316+
RedisModuleRdbStream *stream,
7317+
int flags);
7318+
7319+
**Available since:** unreleased
7320+
7321+
Load RDB file from the `stream`. Dataset will be cleared first and then RDB
7322+
file will be loaded.
7323+
7324+
`flags` must be zero. This parameter is for future use.
7325+
7326+
On success `REDISMODULE_OK` is returned, otherwise `REDISMODULE_ERR` is returned
7327+
and errno is set accordingly.
7328+
7329+
Example:
7330+
7331+
RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb");
7332+
RedisModule_RdbLoad(ctx, s, 0);
7333+
RedisModule_RdbStreamFree(s);
7334+
7335+
<span id="RedisModule_RdbSave"></span>
7336+
7337+
### `RedisModule_RdbSave`
7338+
7339+
int RedisModule_RdbSave(RedisModuleCtx *ctx,
7340+
RedisModuleRdbStream *stream,
7341+
int flags);
7342+
7343+
**Available since:** unreleased
7344+
7345+
Save dataset to the RDB stream.
7346+
7347+
`flags` must be zero. This parameter is for future use.
7348+
7349+
On success `REDISMODULE_OK` is returned, otherwise `REDISMODULE_ERR` is returned
7350+
and errno is set accordingly.
7351+
7352+
Example:
7353+
7354+
RedisModuleRdbStream *s = RedisModule_RdbStreamCreateFromFile("exp.rdb");
7355+
RedisModule_RdbSave(ctx, s, 0);
7356+
RedisModule_RdbStreamFree(s);
7357+
72587358
<span id="section-key-eviction-api"></span>
72597359

72607360
## Key eviction API
@@ -7318,7 +7418,7 @@ returns `REDISMODULE_OK` if when key is valid.
73187418

73197419
### `RedisModule_GetModuleOptionsAll`
73207420

7321-
int RedisModule_GetModuleOptionsAll();
7421+
int RedisModule_GetModuleOptionsAll(void);
73227422

73237423
**Available since:** unreleased
73247424

@@ -7339,7 +7439,7 @@ Example:
73397439

73407440
### `RedisModule_GetContextFlagsAll`
73417441

7342-
int RedisModule_GetContextFlagsAll();
7442+
int RedisModule_GetContextFlagsAll(void);
73437443

73447444
**Available since:** 6.0.9
73457445

@@ -7360,7 +7460,7 @@ Example:
73607460

73617461
### `RedisModule_GetKeyspaceNotificationFlagsAll`
73627462

7363-
int RedisModule_GetKeyspaceNotificationFlagsAll();
7463+
int RedisModule_GetKeyspaceNotificationFlagsAll(void);
73647464

73657465
**Available since:** 6.0.9
73667466

@@ -7381,7 +7481,7 @@ Example:
73817481

73827482
### `RedisModule_GetServerVersion`
73837483

7384-
int RedisModule_GetServerVersion();
7484+
int RedisModule_GetServerVersion(void);
73857485

73867486
**Available since:** 6.0.9
73877487

@@ -7393,7 +7493,7 @@ Example for 6.0.7 the return value will be 0x00060007.
73937493

73947494
### `RedisModule_GetTypeMethodVersion`
73957495

7396-
int RedisModule_GetTypeMethodVersion();
7496+
int RedisModule_GetTypeMethodVersion(void);
73977497

73987498
**Available since:** 6.2.0
73997499

@@ -7852,6 +7952,10 @@ There is no guarantee that this info is always available, so this may return -1.
78527952
* [`RedisModule_PublishMessage`](#RedisModule_PublishMessage)
78537953
* [`RedisModule_PublishMessageShard`](#RedisModule_PublishMessageShard)
78547954
* [`RedisModule_RandomKey`](#RedisModule_RandomKey)
7955+
* [`RedisModule_RdbLoad`](#RedisModule_RdbLoad)
7956+
* [`RedisModule_RdbSave`](#RedisModule_RdbSave)
7957+
* [`RedisModule_RdbStreamCreateFromFile`](#RedisModule_RdbStreamCreateFromFile)
7958+
* [`RedisModule_RdbStreamFree`](#RedisModule_RdbStreamFree)
78557959
* [`RedisModule_Realloc`](#RedisModule_Realloc)
78567960
* [`RedisModule_RedactClientCommandArgument`](#RedisModule_RedactClientCommandArgument)
78577961
* [`RedisModule_RegisterAuthCallback`](#RedisModule_RegisterAuthCallback)
@@ -7879,6 +7983,7 @@ There is no guarantee that this info is always available, so this may return -1.
78797983
* [`RedisModule_ReplyWithEmptyArray`](#RedisModule_ReplyWithEmptyArray)
78807984
* [`RedisModule_ReplyWithEmptyString`](#RedisModule_ReplyWithEmptyString)
78817985
* [`RedisModule_ReplyWithError`](#RedisModule_ReplyWithError)
7986+
* [`RedisModule_ReplyWithErrorFormat`](#RedisModule_ReplyWithErrorFormat)
78827987
* [`RedisModule_ReplyWithLongDouble`](#RedisModule_ReplyWithLongDouble)
78837988
* [`RedisModule_ReplyWithLongLong`](#RedisModule_ReplyWithLongLong)
78847989
* [`RedisModule_ReplyWithMap`](#RedisModule_ReplyWithMap)

0 commit comments

Comments
 (0)