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. 2333: [SCOI2011]棘手的操作[我不玩了]

    2333: [SCOI2011]棘手的操作 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1979  Solved: 772[Submit][Stat ...

  2. JVM内存模型以及垃圾回收

    JAVA堆的描述如下: 内存由Perm和Heap组成.其中Heap = {Old + NEW = { Eden , from, to } } JVM内存模型中分两大块: NEW Generation: ...

  3. windows下安装awstats来分析apache的访问日志

    一.啰嗦两句 之前在Windows下用Apache时,也曾经配置过Awstats,然后换了工作,改用Linux+nginx,渐渐把Apache忘记了.又换了工作,又得用Apache,这回版本更新到2. ...

  4. JavaScript惰性函数定义

    函数是js世界的一等公民,js的动态性.易变性在函数的应用上,体现的淋漓尽致.做为参数,做为返回值等,正是函数这些特性,使得js开发变的有趣. 下面就阐述一下,js一个有趣的应用--惰性函数定义(La ...

  5. 2008 SCI 影响因子(Impact Factor)

    2008 SCI 影响因子(Impact Factor) Excel download 期刊名缩写 影响因子 ISSN号 CA-CANCER J CLIN 74.575 0007-9235 NEW E ...

  6. nyist oj 214 单调递增子序列(二) (动态规划经典)

    单调递增子序列(二) 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描写叙述 ,a2...,an}(0<n<=100000).找出单调递增最长子序列,并求出其长度 ...

  7. datagrid在MVC中的运用08-实现Master-Detail(使用子datagrid)

    本文主要通过一个子datagrid来实现主次表.谢谢Kevin的博文. 代码部分与http://www.cnblogs.com/darrenji/p/3576258.html相似,这里只列出不一样的地 ...

  8. C# 中的动态创建技术

    [转载]原文出处  http://blog.csdn.net/baiyun789/article/details/6156694 第一部分 WinForm控件在窗体中动态居中创建.删除控件及对其赋值 ...

  9. matlab快捷键大全

    原文地址,点此查看 一.常用对象操作 除了一般windows窗口的常用功能键外. 1.!dir 可以查看当前工作目录的文件. !dir& 可以在dos状态下查看. 2.who   可以查看当前 ...

  10. mac 拷贝文件时报错 8060 解决方案

    解决如下: 即某文件夹下出现多重子目录,级数很多,删除多余的子文件夹即可. 至于如何产生的,有人说是xcode升级导致,不过没有见证 .我的不属于这类情况的. (参见:http://macosx.co ...