Home > Database > Redis > body text

Introduction to how pomelo connects to redis

Release: 2020-04-02 10:07:02
forward
2578 people have browsed it

Introduction to how pomelo connects to redis

How to connect pomelo to redis:

1. Add code to app.js

    var redis = require("redis");  
    var client = redis.createClient(6379, "127.0.0.1", {});  // 连接
    
    client.on("error", function (err) {///绑定redis数据库错误回调
        
        console.error("Redis:Error:" + err);
    });
    app.set("redis", client); // app访问接口
Copy after login

2. Add code to GoodsService.js

   var redis= app.get("redis");//获得 redis 对象

        redis.set("name", "caoshanshan", function (err, rep) {  //插入数据
            console.log("Redis:" + rep);//回调
        
        });
Copy after login

3. Test

Introduction to how pomelo connects to redis

Use redisclient-win32.x86.1.0 to view redis data

Introduction to how pomelo connects to redis

4. Close redis , pomelo displays an error message, (binding at app.js)

Introduction to how pomelo connects to redis

Related recommendations:

mysql video tutorial: https: //m.sbmmt.com/course/list/51.html

The above is the detailed content of Introduction to how pomelo connects to redis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:oschina.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!