As we saw in the video, redis can do more than just simple key-value pairs. We are going to be using redis lists later to add persistance to our live-moderation app, so let's practice using them now.

Using the redis client's lpush command, insert the two questions below into the questions list

var redis = require('redis');
var client = redis.createClient(); var question1 = "Where is the dog?";
var question2 = "Where is the cat?"; client.lpush("questions", question1);
client.lpush("questions", question2);

Now that we have seeded the questions list, use the lrange command to return all of the items and log them.

var redis = require('redis');
var client = redis.createClient(); client.lrange('questions', 0, -1, function(err, messages){
console.log(messages);
});

[Node.js]32. Level 7: Working with Lists -- Redis的更多相关文章

  1. [Node.js]31. Level 7: Redis coming for Node.js, Simple Redis Commands

    Let's start practicing using the redis key-value store from our node application. First require the  ...

  2. [Node.js]30. Level 6: Listen 'Question' from client, and then Answer the Question

    Clients can also answer each other questions, so let's build that feature by first listening for the ...

  3. [Node.js]29. Level 6: Socket.io: Setting up Socket.io server-side & Client socket.io setup

    Below we've already created an express server, but we want to start building a real-time Q&A mod ...

  4. [Node.js]24. Level 5: Express, Express routes

    Create an express route that responds to GET requests at the URL /tweets that responds with the file ...

  5. [Node.js]23. Level 4: Semantic versioning

    Update the versions on your dependencies to be a little more flexible, adding the ~ in front of your ...

  6. [Node.js]22. Level 4: Dependency

    Add two dependencies to your package.json file, connect and underscore. You'll want to useconnect ve ...

  7. [Node.js]33. Level 7: Persisting Questions

    Let's go back to our live-moderation app and add some persistence, first to the questions people ask ...

  8. [Node.js]28. Level 5: Express Server

    Now let's create an express server which queries out for this search term and just returns the json. ...

  9. [Node.js]27. Level 5: URL Building & Doing the Request

    Let's create a page which calls the twitter search API and displays the last few results for Code Sc ...

随机推荐

  1. Codeforces Round VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM 暴力出奇迹!

    VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Lim ...

  2. linux_jdk_mysql_tomcat

    1 linux下安装jdk的步骤: 0. 查找原有的jdk: rpm -qa | grep java 删除原有的jdk: rpm -e --nodeps java-1.7.0-openjdk-1.7. ...

  3. ecshop功能目录

    右上 开店向导 1设置商店的一些基本信息 商店的名字.地址.配送方式.支付方式等 2给商店添加一些商品 商品的名称.数量.分类.品牌.价格.描述等 3恭喜您,您的网店可以使用了!下面是一些常用功能的链 ...

  4. 使用Chrome快速实现数据的抓取(五)—— puppeteer

    如果要以自动化的方式驱动Chrome进行数据抓取,必须实现Chrome Dev Protocol协议的客户端.这个协议本身并不复杂,我在之前的文章中也简单的介绍过一下. Google本身有一个Node ...

  5. Openfire 服务器更换ip后的恢复方法

    如果你的服务器名称和mysql的地址都是使用的静态ip地址配置的,更改ip后,openfire就会开启失败,这种情况下请看下面的解决方法. 比如你的ip地址由 192.168.0.111 改为192. ...

  6. 【docker-compose】docker-compose.yml文本内容详解 + docker-compose命令详解 + docker-compose启动服务容器时区设置

    参考地址:https://blog.csdn.net/Kiloveyousmile/article/details/79830810 参考地址:https://docs.docker.com/comp ...

  7. 通过微软的HTML Help Workshop 利用.html文件 生成简单的chm帮助类的文件

    1.下载并安装Microsoft HTML Help Workshop 下载链接:http://www.microsoft.com/en-us/download/details.aspx?id=211 ...

  8. [翻译] EnterTheMatrix

    Enter The Matrix https://github.com/mpospese/EnterTheMatrix The sample application to accompany my c ...

  9. visio 画类图时 方法里如何加参数

    鼠标双击类(打开属性对话框)-->(类别)操作-->属性-->(类别)参数-->(添加参数)

  10. Java发邮件带附件测试通过

    package cn.bric.crm.util; import java.util.Date; import java.util.Enumeration; import java.util.Prop ...