Skip to content

Commit 812723f

Browse files
authored
DEV: fix Lua API right-side nav (#726)
* DEV: fix Lua API right-side nav * Apply review comments
1 parent c551b2f commit 812723f

File tree

1 file changed

+42
-43
lines changed
  • content/develop/interact/programmability

1 file changed

+42
-43
lines changed

content/develop/interact/programmability/lua-api.md

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ The _redis_ singleton is an object instance that's accessible from all scripts.
9393
It provides the API to interact with Redis from scripts.
9494
Its description follows [below](#redis_object).
9595

96-
### <a name="the-keys-global-variable"></a>The _KEYS_ global variable
96+
### The _KEYS_ global variable {#the-keys-global-variable}
9797

9898
* Since version: 2.6.0
9999
* Available in scripts: yes
@@ -107,7 +107,7 @@ Scripts **should never** access keys with programmatically-generated names or ba
107107
The _KEYS_ global variable is available only for [ephemeral scripts]({{< relref "/develop/interact/programmability/eval-intro" >}}).
108108
It is pre-populated with all key name input arguments.
109109

110-
### <a name="the-argv-global-variable"></a>The _ARGV_ global variable
110+
### The _ARGV_ global variable {#the-argv-global-variable}
111111

112112
* Since version: 2.6.0
113113
* Available in scripts: yes
@@ -116,7 +116,7 @@ It is pre-populated with all key name input arguments.
116116
The _ARGV_ global variable is available only in [ephemeral scripts]({{< relref "/develop/interact/programmability/eval-intro" >}}).
117117
It is pre-populated with all regular input arguments.
118118

119-
## <a name="redis_object"></a>_redis_ object
119+
## _redis_ object {#redis_object}
120120

121121
* Since version: 2.6.0
122122
* Available in scripts: yes
@@ -126,7 +126,7 @@ The Redis Lua execution context always provides a singleton instance of an objec
126126
The _redis_ instance enables the script to interact with the Redis server that's running it.
127127
Following is the API provided by the _redis_ object instance.
128128

129-
### <a name="redis.call"></a> `redis.call(command [,arg...])`
129+
### `redis.call(command [,arg...])` {#redis.call}
130130

131131
* Since version: 2.6.0
132132
* Available in scripts: yes
@@ -153,7 +153,7 @@ Note that the call can fail due to various reasons, see [Execution under low mem
153153

154154
To handle Redis runtime errors use `redis.pcall()` instead.
155155

156-
### <a name="redis.pcall"></a> `redis.pcall(command [,arg...])`
156+
### `redis.pcall(command [,arg...])` {#redis.pcall}
157157

158158
* Since version: 2.6.0
159159
* Available in scripts: yes
@@ -184,7 +184,7 @@ redis> EVAL "..." 0 hello world
184184
(error) ERR Something is wrong, but no worries, everything is under control
185185
```
186186

187-
### <a name="redis.error_reply"></a> `redis.error_reply(x)`
187+
### `redis.error_reply(x)` {#redis.error_reply}
188188

189189
* Since version: 2.6.0
190190
* Available in scripts: yes
@@ -217,7 +217,7 @@ Refer to the [Data type conversion](#data-type-conversion) for returning other r
217217
By convention, Redis uses the first word of an error string as a unique error code for specific errors or `ERR` for general-purpose errors.
218218
Scripts are advised to follow this convention, as shown in the example above, but this is not mandatory.
219219

220-
### <a name="redis.status_reply"></a> `redis.status_reply(x)`
220+
### `redis.status_reply(x)` {#redis.status_reply}
221221

222222
* Since version: 2.6.0
223223
* Available in scripts: yes
@@ -247,7 +247,7 @@ TOCK
247247
For returning Redis error replies refer to [`redis.error_reply()`](#redis.error_reply).
248248
Refer to the [Data type conversion](#data-type-conversion) for returning other response types.
249249

250-
### <a name="redis.sha1hex"></a> `redis.sha1hex(x)`
250+
### `redis.sha1hex(x)` {#redis.sha1hex}
251251

252252
* Since version: 2.6.0
253253
* Available in scripts: yes
@@ -262,7 +262,7 @@ redis> EVAL "return redis.sha1hex('')" 0
262262
"da39a3ee5e6b4b0d3255bfef95601890afd80709"
263263
```
264264

265-
### <a name="redis.log"></a> `redis.log(level, message)`
265+
### `redis.log(level, message)` {#redis.log}
266266

267267
* Since version: 2.6.0
268268
* Available in scripts: yes
@@ -294,7 +294,7 @@ will produce a line similar to the following in your server's log:
294294
[32343] 22 Mar 15:21:39 # Something is terribly wrong
295295
```
296296

297-
### <a name="redis.setresp"></a> `redis.setresp(x)`
297+
### `redis.setresp(x)` {#redis.setresp}
298298

299299
* Since version: 6.0.0
300300
* Available in scripts: yes
@@ -312,7 +312,7 @@ redis.setresp(3)
312312

313313
Please refer to the [Data type conversion](#data-type-conversion) for more information about type conversions.
314314

315-
### <a name="redis.set_repl"></a> `redis.set_repl(x)`
315+
### `redis.set_repl(x)` {#redis.set_repl}
316316

317317
* Since version: 3.2.0
318318
* Available in scripts: yes
@@ -367,7 +367,7 @@ redis.call('SET', KEYS[3], ARGV[3])
367367

368368
If you run this script by calling `EVAL "..." 3 A B C 1 2 3`, the result will be that only the keys _A_ and _C_ are created on the replicas and AOF.
369369

370-
### <a name="redis.replicate_commands"></a> `redis.replicate_commands()`
370+
### `redis.replicate_commands()` {#redis.replicate_commands}
371371

372372
* Since version: 3.2.0
373373
* Until version: 7.0.0
@@ -382,23 +382,23 @@ as of Redis v7.0, verbatim script replication is no longer supported.
382382
The default, and only script replication mode supported, is script effects' replication.
383383
For more information, please refer to [`Replicating commands instead of scripts`]({{< relref "/develop/interact/programmability/eval-intro#replicating-commands-instead-of-scripts" >}})
384384

385-
### <a name="redis.breakpoint"></a> `redis.breakpoint()`
385+
### `redis.breakpoint()` {#redis.breakpoint}
386386

387387
* Since version: 3.2.0
388388
* Available in scripts: yes
389389
* Available in functions: no
390390

391391
This function triggers a breakpoint when using the [Redis Lua debugger]({{< relref "/develop/interact/programmability/lua-debugging" >}}).
392392

393-
### <a name="redis.debug"></a> `redis.debug(x)`
393+
### `redis.debug(x)` {#redis.debug}
394394

395395
* Since version: 3.2.0
396396
* Available in scripts: yes
397397
* Available in functions: no
398398

399399
This function prints its argument in the [Redis Lua debugger]({{< relref "/develop/interact/programmability/lua-debugging" >}}) console.
400400

401-
### <a name="redis.acl_check_cmd"></a> `redis.acl_check_cmd(command [,arg...])`
401+
### `redis.acl_check_cmd(command [,arg...])` {#redis.acl_check_cmd}
402402

403403
* Since version: 7.0.0
404404
* Available in scripts: yes
@@ -410,7 +410,7 @@ The return value is a boolean `true` in case the current user has permissions to
410410

411411
The function will raise an error if the passed command or its arguments are invalid.
412412

413-
### <a name="redis.register_function"></a> `redis.register_function`
413+
### `redis.register_function` {#redis.register_function}
414414

415415
* Since version: 7.0.0
416416
* Available in scripts: no
@@ -420,8 +420,7 @@ This function is only available from the context of the [`FUNCTION LOAD`]({{< re
420420
When called, it registers a function to the loaded library.
421421
The function can be called either with positional or named arguments.
422422

423-
#### <a name="redis.register_function_pos_args"></a> positional arguments: `redis.register_function(name, callback)`
424-
423+
#### positional arguments: `redis.register_function(name, callback)` {#redis.register_function_pos_args}
425424
The first argument to `redis.register_function` is a Lua string representing the function name.
426425
The second argument to `redis.register_function` is a Lua function.
427426

@@ -431,7 +430,7 @@ Usage example:
431430
redis> FUNCTION LOAD "#!lua name=mylib\n redis.register_function('noop', function() end)"
432431
```
433432

434-
#### <a name="redis.register_function_named_args"></a> Named arguments: `redis.register_function{function_name=name, callback=callback, flags={flag1, flag2, ..}, description=description}`
433+
#### Named arguments: `redis.register_function{function_name=name, callback=callback, flags={flag1, flag2, ..}, description=description}` {#redis.register_function_named_args}
435434

436435
The named arguments variant accepts the following arguments:
437436

@@ -448,7 +447,7 @@ Usage example:
448447
redis> FUNCTION LOAD "#!lua name=mylib\n redis.register_function{function_name='noop', callback=function() end, flags={ 'no-writes' }, description='Does nothing'}"
449448
```
450449

451-
#### <a name="script_flags"></a> Script flags
450+
#### Script flags {#script_flags}
452451

453452
**Important:**
454453
Use script flags with care, which may negatively impact if misused.
@@ -510,7 +509,7 @@ You can use the following flags and instruct the server to treat the scripts' ex
510509

511510
Please refer to [Function Flags]({{< baseurl >}}/develop/interact/programmability/functions-intro#function-flags) and [Eval Flags]({{< baseurl >}}/develop/interact/programmability/eval-intro#eval-flags) for a detailed example.
512511

513-
### <a name="redis.redis_version"></a> `redis.REDIS_VERSION`
512+
### `redis.REDIS_VERSION` {#redis.redis_version}
514513

515514
* Since version: 7.0.0
516515
* Available in scripts: yes
@@ -523,7 +522,7 @@ The reply's format is `MM.mm.PP`, where:
523522
* **mm:** is the minor version.
524523
* **PP:** is the patch level.
525524

526-
### <a name="redis.redis_version_num"></a> `redis.REDIS_VERSION_NUM`
525+
### `redis.REDIS_VERSION_NUM` {#redis.redis_version_num}
527526

528527
* Since version: 7.0.0
529528
* Available in scripts: yes
@@ -661,7 +660,7 @@ That means, for example, that returning the RESP3 map type to a RESP2 connection
661660

662661
## Additional notes about scripting
663662

664-
### Using [`SELECT`]({{< relref "/commands/select" >}}) inside scripts
663+
### Using `SELECT` inside scripts
665664

666665
You can call the [`SELECT`]({{< relref "/commands/select" >}}) command from your Lua scripts, like you can with any normal client connection.
667666
However, one subtle aspect of the behavior changed between Redis versions 2.8.11 and 2.8.12.
@@ -687,7 +686,7 @@ In addition, the following external libraries are loaded and accessible to scrip
687686
* The [_cmsgpack_ library](#cmsgpack-library)
688687
* The [_bitop_ library](#bitop-library)
689688

690-
### <a name="os-library"></a> _os_ library
689+
### _os_ library {#os-library}
691690

692691
* Since version: 7.4
693692
* Available in scripts: yes
@@ -699,7 +698,7 @@ Note that for sandbox security, currently only the following os functions is exp
699698

700699
* `os.clock()`
701700

702-
### <a name="struct-library"></a> _struct_ library
701+
### _struct_ library {#struct-library}
703702

704703
* Since version: 2.6.0
705704
* Available in scripts: yes
@@ -714,7 +713,7 @@ It provides the following functions:
714713

715714
All of _struct_'s functions expect their first argument to be a [format string](#struct-formats).
716715

717-
#### <a name="struct-formats"></a> _struct_ formats
716+
#### _struct_ formats {#struct-formats}
718717

719718
The following are valid format strings for _struct_'s functions:
720719

@@ -735,7 +734,7 @@ The following are valid format strings for _struct_'s functions:
735734
* `d`: double
736735
* ` ` (space): ignored
737736

738-
#### <a name="struct.pack"></a> `struct.pack(x)`
737+
#### `struct.pack(x)` {#struct.pack}
739738

740739
This function returns a struct-encoded string from values.
741740
It accepts a [_struct_ format string](#struct-formats) as its first argument, followed by the values that are to be encoded.
@@ -747,7 +746,7 @@ redis> EVAL "return struct.pack('HH', 1, 2)" 0
747746
"\x01\x00\x02\x00"
748747
```
749748

750-
#### <a name="struct.unpack"></a> `struct.unpack(x)`
749+
#### `struct.unpack(x)` {#struct.unpack}
751750

752751
This function returns the decoded values from a struct.
753752
It accepts a [_struct_ format string](#struct-formats) as its first argument, followed by encoded struct's string.
@@ -761,7 +760,7 @@ redis> EVAL "return { struct.unpack('HH', ARGV[1]) }" 0 "\x01\x00\x02\x00"
761760
3) (integer) 5
762761
```
763762

764-
#### <a name="struct.size"></a> `struct.size(x)`
763+
#### `struct.size(x)` {#struct.size}
765764

766765
This function returns the size, in bytes, of a struct.
767766
It accepts a [_struct_ format string](#struct-formats) as its only argument.
@@ -773,7 +772,7 @@ redis> EVAL "return struct.size('HH')" 0
773772
(integer) 4
774773
```
775774

776-
### <a name="cjson-library"></a> _cjson_ library
775+
### _cjson_ library {#cjson-library}
777776

778777
* Since version: 2.6.0
779778
* Available in scripts: yes
@@ -782,7 +781,7 @@ redis> EVAL "return struct.size('HH')" 0
782781
The _cjson_ library provides fast [JSON](https://json.org) encoding and decoding from Lua.
783782
It provides these functions.
784783

785-
#### <a name="cjson.encode()"></a> `cjson.encode(x)`
784+
#### `cjson.encode(x)` {#cjson.encode}
786785

787786
This function returns a JSON-encoded string for the Lua data type provided as its argument.
788787

@@ -793,7 +792,7 @@ redis> EVAL "return cjson.encode({ ['foo'] = 'bar' })" 0
793792
"{\"foo\":\"bar\"}"
794793
```
795794

796-
#### <a name="cjson.decode()"></a> `cjson.decode(x)`
795+
#### `cjson.decode(x)` {#cjson.decode()}
797796

798797
This function returns a Lua data type from the JSON-encoded string provided as its argument.
799798

@@ -804,7 +803,7 @@ redis> EVAL "return cjson.decode(ARGV[1])['foo']" 0 '{"foo":"bar"}'
804803
"bar"
805804
```
806805

807-
### <a name="cmsgpack-library"></a> _cmsgpack_ library
806+
### _cmsgpack_ library {#cmsgpack-library}
808807

809808
* Since version: 2.6.0
810809
* Available in scripts: yes
@@ -813,7 +812,7 @@ redis> EVAL "return cjson.decode(ARGV[1])['foo']" 0 '{"foo":"bar"}'
813812
The _cmsgpack_ library provides fast [MessagePack](https://msgpack.org/index.html) encoding and decoding from Lua.
814813
It provides these functions.
815814

816-
#### <a name="cmsgpack.pack()"></a> `cmsgpack.pack(x)`
815+
#### `cmsgpack.pack(x)` {#cmsgpack.pack()}
817816

818817
This function returns the packed string encoding of the Lua data type it is given as an argument.
819818

@@ -824,7 +823,7 @@ redis> EVAL "return cmsgpack.pack({'foo', 'bar', 'baz'})" 0
824823
"\x93\xa3foo\xa3bar\xa3baz"
825824
```
826825

827-
#### <a name="cmsgpack.unpack()"></a> `cmsgpack.unpack(x)`
826+
#### `cmsgpack.unpack(x)` {#cmsgpack.unpack()}
828827

829828
This function returns the unpacked values from decoding its input string argument.
830829

@@ -837,7 +836,7 @@ redis> EVAL "return cmsgpack.unpack(ARGV[1])" 0 "\x93\xa3foo\xa3bar\xa3baz"
837836
3) "baz"
838837
```
839838

840-
### <a name="bitop-library"></a> _bit_ library
839+
### _bit_ library {#bitop-library}
841840

842841
* Since version: 2.8.18
843842
* Available in scripts: yes
@@ -847,7 +846,7 @@ The _bit_ library provides bitwise operations on numbers.
847846
Its documentation resides at [Lua BitOp documentation](http://bitop.luajit.org/api.html)
848847
It provides the following functions.
849848

850-
#### <a name="bit.tobit()"></a> `bit.tobit(x)`
849+
#### `bit.tobit(x)` {#bit.tobit()}
851850

852851
Normalizes a number to the numeric range for bit operations and returns it.
853852

@@ -858,7 +857,7 @@ redis> EVAL 'return bit.tobit(1)' 0
858857
(integer) 1
859858
```
860859

861-
#### <a name="bit.tohex()"></a> `bit.tohex(x [,n])`
860+
#### `bit.tohex(x [,n])` {#bit.tohex()}
862861

863862
Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument.
864863

@@ -869,11 +868,11 @@ redis> EVAL 'return bit.tohex(422342)' 0
869868
"000671c6"
870869
```
871870

872-
#### <a name="bit.bnot()"></a> `bit.bnot(x)`
871+
#### `bit.bnot(x)` {#bit.bnot()}
873872

874873
Returns the bitwise **not** of its argument.
875874

876-
#### <a name="bit.ops"></a> `bit.bnot(x)` `bit.bor(x1 [,x2...])`, `bit.band(x1 [,x2...])` and `bit.bxor(x1 [,x2...])`
875+
#### `bit.bnot(x)` `bit.bor(x1 [,x2...])`, `bit.band(x1 [,x2...])` and `bit.bxor(x1 [,x2...])` {#bit.ops}
877876

878877
Returns either the bitwise **or**, bitwise **and**, or bitwise **xor** of all of its arguments.
879878
Note that more than two arguments are allowed.
@@ -885,16 +884,16 @@ redis> EVAL 'return bit.bor(1,2,4,8,16,32,64,128)' 0
885884
(integer) 255
886885
```
887886

888-
#### <a name="bit.shifts"></a> `bit.lshift(x, n)`, `bit.rshift(x, n)` and `bit.arshift(x, n)`
887+
#### `bit.lshift(x, n)`, `bit.rshift(x, n)` and `bit.arshift(x, n)` {#bit.shifts}
889888

890889
Returns either the bitwise logical **left-shift**, bitwise logical **right-shift**, or bitwise **arithmetic right-shift** of its first argument by the number of bits given by the second argument.
891890

892-
#### <a name="bit.ro"></a> `bit.rol(x, n)` and `bit.ror(x, n)`
891+
#### `bit.rol(x, n)` and `bit.ror(x, n)` {#bit.ro}
893892

894893
Returns either the bitwise **left rotation**, or bitwise **right rotation** of its first argument by the number of bits given by the second argument.
895894
Bits shifted out on one side are shifted back in on the other side.
896895

897-
#### <a name="bit.bswap()"></a> `bit.bswap(x)`
896+
#### `bit.bswap(x)` {#bit.bswap()}
898897

899898
Swaps the bytes of its argument and returns it.
900899
This can be used to convert little-endian 32-bit numbers to big-endian 32-bit numbers and vice versa.

0 commit comments

Comments
 (0)