GithubHelp home page GithubHelp logo

redis-nodejs-client-sample's Introduction

Redis Node.js Client Sample

사전 준비

  • node.js가 설치되어 있어야 합니다. https://nodejs.org/ko/download/ 사이트에서 OS에 맞도록 설치하세요.
  • 예제를 실행하는 폴더에서 아래 명령어를 이용하여 ioredis 모듈을 설치해야 합니다. 명령어 실행하면 node_modules 폴더가 생성됩니다.
$ npm install ioredis

파일 설명

redis-client-master.js

redis master 서버에 접속하여 set, get 실행하는 node.js로 작성된 파일입니다.
실행 하고 5초 후에 프로그램이 종료되도록 되어 있습니다.
"node redis-client-master.js" 명령어로 실행하면 됩니다.

redis-client-slave.js

redis slave 서버에 접속하여 set, get 실행합니다.
slave 서버는 read 전용이므로 set 실행하면 에러가 발생하도록 되어 있습니다. 즉, 에러가 발생해야 정상입니다.
get 은 실행이 되고 null 값이 조회 되어야 정상입니다.
만약, redis-client-master.js 가 실행되고 있다면 이 프로그램에서 set 한 value 인 "hong gil dong" 이 조회 됩니다.

실행 방법

Redis master client sample 실행

$ node redis-client-master.js

실행 결과

저장 key : name
저장 value : hong gil dong
저장 result : OK
조회 key : name
조회 value : hong gil dong

Redis slave client sample 실행

$ node redis-client-slave.js

실행 결과

ReplyError: READONLY You can't write against a read only replica.
    at parseError (/Users/ounju-kim/redis-nodejs-client-sample/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/Users/ounju-kim/redis-nodejs-client-sample/node_modules/redis-parser/lib/parser.js:302:14) {
  command: { name: 'set', args: [ 'name', 'hong gil dong' ] }
}
조회 key : name
조회 value : null
  • read 전용 서버이기 때문에 set 실행하면 에러가 발생하는게 정상입니다.
  • set 한 값이 없기 때문에 "null" 이 조회되는게 정상입니다.

redis-nodejs-client-sample's People

Contributors

ounju avatar

Watchers

changyu.seon avatar James Cloos avatar lemy0715 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.