博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Node.js]32. Level 7: Working with Lists -- Redis
阅读量:7051 次
发布时间:2019-06-28

本文共 763 字,大约阅读时间需要 2 分钟。

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);});

 

转载地址:http://fesol.baihongyu.com/

你可能感兴趣的文章
Confluence 6 空间标识
查看>>
使用kubeadm安装Kubernetes v1.10以及常见问题解答
查看>>
Linux FTP上传脚本
查看>>
Robot Framework之pymysql数据库查询
查看>>
干货 | 机器学习没有你想的那么复杂
查看>>
PostgreSQL 10.1 手册_部分 III. 服务器管理_第 16 章 从源代码安装_16.1. 简单版
查看>>
springMVC的事务不回滚
查看>>
WPF与缓动(三) 指数缓动
查看>>
UPS电源和EPS电源的主要区别
查看>>
虚拟接VMnet1 和VMnet8的区别
查看>>
爱奇艺体育获5亿元战略融资 ,IDG资本、汇盈博润领投
查看>>
三目运算-高级嵌套用法思路教程
查看>>
从编程小白到全栈开发:寻找代码中的问题
查看>>
如何处理地图投影转换
查看>>
区块链技术公司 看区块链数据如何实现安全共享
查看>>
HttpClient-4.5总结(1)
查看>>
Linux_异常_03_Failed to restart iptables.service: Unit not found.
查看>>
LeetCode 169 Majority Element(主要元素)(vector、map)
查看>>
mysql中的几个常用的方法
查看>>
Google 的Android Splash
查看>>