@upstash/redis 1.6.1-next.1 → 1.6.1
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 +80 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,9 +11,9 @@ It is the only connectionless (HTTP based) Redis client and designed for:
|
|
|
11
11
|
|
|
12
12
|
- Serverless functions (AWS Lambda ...)
|
|
13
13
|
- Cloudflare Workers (see
|
|
14
|
-
[the example](https://github.com/upstash/upstash-redis/tree/
|
|
14
|
+
[the example](https://github.com/upstash/upstash-redis/tree/main/examples/cloudflare-workers))
|
|
15
15
|
- Fastly Compute@Edge (see
|
|
16
|
-
[the example](https://github.com/upstash/upstash-redis/tree/
|
|
16
|
+
[the example](https://github.com/upstash/upstash-redis/tree/main/examples/fastly))
|
|
17
17
|
- Next.js, Jamstack ...
|
|
18
18
|
- Client side web/mobile applications
|
|
19
19
|
- WebAssembly
|
|
@@ -23,11 +23,86 @@ See
|
|
|
23
23
|
[the list of APIs](https://docs.upstash.com/features/restapi#rest---redis-api-compatibility)
|
|
24
24
|
supported.
|
|
25
25
|
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
### Install
|
|
29
|
+
|
|
30
|
+
#### npm
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @upstash/redis
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Deno
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { Redis } from "https://deno.land/x/upstash_redis/mod.ts";
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Create database
|
|
43
|
+
|
|
44
|
+
Create a new redis database on [upstash](https://console.upstash.com/)
|
|
45
|
+
|
|
46
|
+
## Basic Usage:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { Redis } from "@upstash/redis"
|
|
50
|
+
|
|
51
|
+
const redis = new Redis({
|
|
52
|
+
url: <UPSTASH_REDIS_REST_URL>,
|
|
53
|
+
token: <UPSTASH_REDIS_REST_TOKEN>,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
// string
|
|
57
|
+
await redis.set('key', 'value');
|
|
58
|
+
let data = await redis.get('key');
|
|
59
|
+
console.log(data)
|
|
60
|
+
|
|
61
|
+
await redis.set('key2', 'value2', {ex: 1});
|
|
62
|
+
|
|
63
|
+
// sorted set
|
|
64
|
+
await redis.zadd('scores', { score: 1, member: 'team1' })
|
|
65
|
+
data = await redis.zrange('scores', 0, 100 )
|
|
66
|
+
console.log(data)
|
|
67
|
+
|
|
68
|
+
// list
|
|
69
|
+
await redis.lpush('elements', 'magnesium')
|
|
70
|
+
data = await redis.lrange('elements', 0, 100 )
|
|
71
|
+
console.log(data)
|
|
72
|
+
|
|
73
|
+
// hash
|
|
74
|
+
await redis.hset('people', {name: 'joe'})
|
|
75
|
+
data = await redis.hget('people', 'name' )
|
|
76
|
+
console.log(data)
|
|
77
|
+
|
|
78
|
+
// sets
|
|
79
|
+
await redis.sadd('animals', 'cat')
|
|
80
|
+
data = await redis.spop('animals', 1)
|
|
81
|
+
console.log(data)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Upgrading to v1.4.0 **(ReferenceError: fetch is not defined)**
|
|
85
|
+
|
|
86
|
+
If you are running on nodejs v17 and earlier, `fetch` will not be natively
|
|
87
|
+
supported. Platforms like Vercel, Netlify, Deno, Fastly etc. provide a polyfill
|
|
88
|
+
for you. But if you are running on bare node, you need to either specify a
|
|
89
|
+
polyfill yourself or change the import path to:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { Redis } from "@upstash/redis/with-fetch";
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Upgrading from v0.2.0?
|
|
96
|
+
|
|
97
|
+
Please read the
|
|
98
|
+
[migration guide](https://docs.upstash.com/redis/sdks/javascriptsdk/migration).
|
|
99
|
+
For further explanation we wrote a
|
|
100
|
+
[blog post](https://blog.upstash.com/upstash-redis-sdk-v1).
|
|
101
|
+
|
|
26
102
|
## Docs
|
|
27
103
|
|
|
28
|
-
See
|
|
29
|
-
|
|
30
|
-
for details.
|
|
104
|
+
See [the documentation](https://docs.upstash.com/features/javascriptsdk) for
|
|
105
|
+
details.
|
|
31
106
|
|
|
32
107
|
## Contributing
|
|
33
108
|
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
"main": "./script/platforms/nodejs.js",
|
|
4
4
|
"types": "./types/platforms/nodejs.d.ts",
|
|
5
5
|
"name": "@upstash/redis",
|
|
6
|
+
"version": "v1.6.1",
|
|
6
7
|
"description": "An HTTP/REST based Redis client built on top of Upstash REST API.",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
@@ -96,6 +97,5 @@
|
|
|
96
97
|
"require": "./script/platforms/node_with_fetch.js",
|
|
97
98
|
"types": "./types/platforms/node_with_fetch.d.ts"
|
|
98
99
|
}
|
|
99
|
-
}
|
|
100
|
-
"version": "1.6.1-next.1"
|
|
100
|
+
}
|
|
101
101
|
}
|