Skip to content

Commit 34c7331

Browse files
committed
setup redis
1 parent 70f9fca commit 34c7331

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"@babel/preset-typescript": "^7.15.0",
1818
"@types/dotenv-flow": "^3.2.0",
1919
"@types/express": "^4.17.13",
20+
"@types/ioredis": "^4.27.6",
2021
"@types/node": "^16.10.2",
2122
"@typescript-eslint/eslint-plugin": "^4.33.0",
2223
"@typescript-eslint/parser": "^4.33.0",
@@ -39,6 +40,7 @@
3940
"@prisma/client": "^3.1.1",
4041
"dotenv-flow": "^3.2.0",
4142
"express": "^4.17.1",
42-
"express-async-errors": "^3.1.1"
43+
"express-async-errors": "^3.1.1",
44+
"ioredis": "^4.27.10"
4345
}
4446
}

src/redis/client.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Redis from 'ioredis'
2+
import { promisify } from 'util'
3+
4+
const redis = new Redis()
5+
6+
const getRedis = (value: string): any => {
7+
const asyncRedisGet = promisify(redis.get).bind(redis)
8+
return asyncRedisGet(value)
9+
}
10+
11+
const setRedis = (key: string, value: string): any => {
12+
const asyncRedisSet = promisify(redis.set).bind(redis)
13+
return asyncRedisSet(key, value)
14+
}
15+
16+
export { redis, getRedis, setRedis }

src/redis/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './client'

yarn.lock

+76
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,13 @@
10501050
"@types/qs" "*"
10511051
"@types/serve-static" "*"
10521052

1053+
"@types/ioredis@^4.27.6":
1054+
version "4.27.6"
1055+
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.27.6.tgz#06f2826ca9bcf4e9c179cd11417a4d0413903cba"
1056+
integrity sha512-3FeeDlVQ2sdbvU436XnZzOiDMMgFbKfIsiUF2BnJnH7xxqCbJ1teJwfcu9fLwnfmV0qH2W1Vg3jFrtOehNIkMA==
1057+
dependencies:
1058+
"@types/node" "*"
1059+
10531060
"@types/json-schema@^7.0.7":
10541061
version "7.0.9"
10551062
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
@@ -1448,6 +1455,11 @@ clone-deep@^4.0.1:
14481455
kind-of "^6.0.2"
14491456
shallow-clone "^3.0.0"
14501457

1458+
cluster-key-slot@^1.1.0:
1459+
version "1.1.0"
1460+
resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz#30474b2a981fb12172695833052bc0d01336d10d"
1461+
integrity sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==
1462+
14511463
color-convert@^1.9.0:
14521464
version "1.9.3"
14531465
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
@@ -1576,6 +1588,11 @@ define-properties@^1.1.3:
15761588
dependencies:
15771589
object-keys "^1.0.12"
15781590

1591+
denque@^1.1.0:
1592+
version "1.5.1"
1593+
resolved "https://registry.yarnpkg.com/denque/-/denque-1.5.1.tgz#07f670e29c9a78f8faecb2566a1e2c11929c5cbf"
1594+
integrity sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==
1595+
15791596
depd@~1.1.2:
15801597
version "1.1.2"
15811598
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
@@ -2310,6 +2327,23 @@ internal-slot@^1.0.3:
23102327
has "^1.0.3"
23112328
side-channel "^1.0.4"
23122329

2330+
ioredis@^4.27.10:
2331+
version "4.27.10"
2332+
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.27.10.tgz#3da6c1d2eab440f94c52d6fcd9b91127d7e07470"
2333+
integrity sha512-BtV2mEoZlhnW0EyxuK49V5iutLeZeJAYi/+Fuc4Q6DpDjq0cGMLODdS/+Kb5CHpT7v3YT6SK0vgJF6y0Ls4+Bg==
2334+
dependencies:
2335+
cluster-key-slot "^1.1.0"
2336+
debug "^4.3.1"
2337+
denque "^1.1.0"
2338+
lodash.defaults "^4.2.0"
2339+
lodash.flatten "^4.4.0"
2340+
lodash.isarguments "^3.1.0"
2341+
p-map "^2.1.0"
2342+
redis-commands "1.7.0"
2343+
redis-errors "^1.2.0"
2344+
redis-parser "^3.0.0"
2345+
standard-as-callback "^2.1.0"
2346+
23132347
ipaddr.js@1.9.1:
23142348
version "1.9.1"
23152349
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3"
@@ -2557,6 +2591,21 @@ lodash.debounce@^4.0.8:
25572591
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
25582592
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
25592593

2594+
lodash.defaults@^4.2.0:
2595+
version "4.2.0"
2596+
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
2597+
integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=
2598+
2599+
lodash.flatten@^4.4.0:
2600+
version "4.4.0"
2601+
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"
2602+
integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=
2603+
2604+
lodash.isarguments@^3.1.0:
2605+
version "3.1.0"
2606+
resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a"
2607+
integrity sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=
2608+
25602609
lodash.merge@^4.6.2:
25612610
version "4.6.2"
25622611
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
@@ -2804,6 +2853,11 @@ p-locate@^3.0.0:
28042853
dependencies:
28052854
p-limit "^2.0.0"
28062855

2856+
p-map@^2.1.0:
2857+
version "2.1.0"
2858+
resolved "https://registry.yarnpkg.com/p-map/-/p-map-2.1.0.tgz#310928feef9c9ecc65b68b17693018a665cea175"
2859+
integrity sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==
2860+
28072861
p-try@^1.0.0:
28082862
version "1.0.0"
28092863
resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3"
@@ -3022,6 +3076,23 @@ readdirp@~3.6.0:
30223076
dependencies:
30233077
picomatch "^2.2.1"
30243078

3079+
redis-commands@1.7.0:
3080+
version "1.7.0"
3081+
resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.7.0.tgz#15a6fea2d58281e27b1cd1acfb4b293e278c3a89"
3082+
integrity sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==
3083+
3084+
redis-errors@^1.0.0, redis-errors@^1.2.0:
3085+
version "1.2.0"
3086+
resolved "https://registry.yarnpkg.com/redis-errors/-/redis-errors-1.2.0.tgz#eb62d2adb15e4eaf4610c04afe1529384250abad"
3087+
integrity sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=
3088+
3089+
redis-parser@^3.0.0:
3090+
version "3.0.0"
3091+
resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-3.0.0.tgz#b66d828cdcafe6b4b8a428a7def4c6bcac31c8b4"
3092+
integrity sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=
3093+
dependencies:
3094+
redis-errors "^1.0.0"
3095+
30253096
regenerate-unicode-properties@^9.0.0:
30263097
version "9.0.0"
30273098
resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-9.0.0.tgz#54d09c7115e1f53dc2314a974b32c1c344efe326"
@@ -3286,6 +3357,11 @@ sprintf-js@~1.0.2:
32863357
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
32873358
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=
32883359

3360+
standard-as-callback@^2.1.0:
3361+
version "2.1.0"
3362+
resolved "https://registry.yarnpkg.com/standard-as-callback/-/standard-as-callback-2.1.0.tgz#8953fc05359868a77b5b9739a665c5977bb7df45"
3363+
integrity sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==
3364+
32893365
"statuses@>= 1.5.0 < 2", statuses@~1.5.0:
32903366
version "1.5.0"
32913367
resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c"

0 commit comments

Comments
 (0)