inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

ssongkr님의 게시글

ssongkr ssongkr

@ssongkr5541

수강평 작성수
-
평균평점
-

게시글 1

질문&답변

docker-compose up 시 오류

저는 아래 방법으로 해결하였습니다. 공식 문서에 따르면 Redis 3 버전은 Promise를 지원하지 않는다고 하네요. 따라서 util 라이브러리를 이용하여 문제를 해결해야합니다. (dependencies util 추가) Node Redis currently doesn't natively support promises (this is coming in v4), however you can wrap the methods you want to use with promises using the built-in Node.js util.promisify method on Node.js >= v8; const { promisify } = require("util"); const getAsync = promisify(client.get).bind(client); getAsync.then(console.log).catch(console.error); const express = require("express"); const redis = require("redis"); const { promisify } = require("util"); //레디스 클라이언트 생성 const client = redis.createClient({ host: "redis-server", port: 6379 }); const getAsync = promisify(client.get).bind(client); const setAsync = promisify(client.set).bind(client); client.on('error',err => console.log('Redis Client Error',err)); const app = express(); app.get('/',async (req,res) => { let number = await getAsync('number'); if (number === null) { number = 0; } res.send("숫자가 1씩 올라갑니다. 숫자: " + (parseInt(number))); await setAsync('number', (parseInt(number) + 1)) }) app.listen(8080); console.log('Server is running');

좋아요수
0
댓글수
7
조회수
2813