ioredis 5.0.5 → 5.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -10
- package/built/Pipeline.d.ts +3 -0
- package/built/utils/RedisCommander.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -102,13 +102,13 @@ Medis starts with all the basic features you need:
|
|
|
102
102
|
## Install
|
|
103
103
|
|
|
104
104
|
```shell
|
|
105
|
-
|
|
105
|
+
npm install ioredis
|
|
106
106
|
```
|
|
107
107
|
|
|
108
108
|
In a TypeScript project, you may want to add TypeScript declarations for Node.js:
|
|
109
109
|
|
|
110
110
|
```shell
|
|
111
|
-
|
|
111
|
+
npm install --save-dev @types/node
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
## Basic Usage
|
|
@@ -312,19 +312,27 @@ listenForMessage();
|
|
|
312
312
|
|
|
313
313
|
## Handle Binary Data
|
|
314
314
|
|
|
315
|
-
|
|
315
|
+
Binary data support is out of the box. Pass buffers to send binary data:
|
|
316
316
|
|
|
317
317
|
```javascript
|
|
318
|
-
redis.set("foo", Buffer.from(
|
|
318
|
+
redis.set("foo", Buffer.from([0x62, 0x75, 0x66]));
|
|
319
319
|
```
|
|
320
320
|
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
Every command that returns a [bulk string](https://redis.io/docs/reference/protocol-spec/#resp-bulk-strings)
|
|
322
|
+
has a variant command with a `Buffer` suffix. The variant command returns a buffer instead of a UTF-8 string:
|
|
323
323
|
|
|
324
324
|
```javascript
|
|
325
|
-
redis.getBuffer("foo"
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
const result = await redis.getBuffer("foo");
|
|
326
|
+
// result is `<Buffer 62 75 66>`
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
It's worth noticing that you don't need the `Buffer` suffix variant in order to **send** binary data. That means
|
|
330
|
+
in most case you should just use `redis.set()` instead of `redis.setBuffer()` unless you want to get the old value
|
|
331
|
+
with the `GET` parameter:
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
const result = await redis.setBuffer("foo", "new value", "GET");
|
|
335
|
+
// result is `<Buffer 62 75 66>` as `GET` indicates returning the old value.
|
|
328
336
|
```
|
|
329
337
|
|
|
330
338
|
## Pipelining
|
|
@@ -1388,7 +1396,7 @@ default, this option is disabled and can only be used for debugging purposes. Yo
|
|
|
1388
1396
|
Start a Redis server on 127.0.0.1:6379, and then:
|
|
1389
1397
|
|
|
1390
1398
|
```shell
|
|
1391
|
-
|
|
1399
|
+
npm test
|
|
1392
1400
|
```
|
|
1393
1401
|
|
|
1394
1402
|
`FLUSH ALL` will be invoked after each test, so make sure there's no valuable data in it before running tests.
|
package/built/Pipeline.d.ts
CHANGED