[Node.js]32. Level 7: Working with Lists -- Redis
2023-09-14 08:59:21 时间
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); });
相关文章
- Redis实现数据映射的好处(redis映射)
- Node.js与Redis的高效组合(nodejsredis)
- 使用Node.js实现对MSSQL数据库的连接(node连接 mssql)
- 利用Node.js封装MSSQL的尝试(node mssql封装)
- 群晖Redis加速网站,让你的网站速度更上一级(群晖redis加速网站)
- 深入探索如何查看Redis服务状态(查看redis服务状态)
- 电商Redis队列一场火爆的抢购狂欢(电商redis队列抢购)
- 机器即将重启重新启动Redis(机器要重启 redis)
- 排行榜实现你的梦想,用Redis更快速(排行榜redis实现)
- 从前端JS里请求Redis资源,搭建高性能应用(前端js请求redis)
- 探究Redis的内存占用(如何看redis占用空间)
- 从镜像Redis反思进步(什么是镜像redis)
- 在Lua中玩转Redis妙用千百(在lua中redis)
- 如何正确关闭Redis(redis需要手动关闭么)
- 机制Redis加强事务保障(redis需要加事务)
- Redis集群部署哨兵最佳实践方案(redis集群部署哨兵)
- Redis集群槽点数量的优化方案(redis集群槽点数量)
- 利用Redis集群解决复杂排序问题(redis集群排序问题)
- 利用Redis实现高效的Node限流(redis限流node)
- Redis中的订阅机制及其在JS中的应用(redis 订阅 js)
- Redis和JavaScript的结合实现了何种不可思议的奇迹(redis能在js连接吗)
- 突破性应用Redis编程技术(redis编程中的应用)
- 利用Redis汇集数据,助力数据统计(redis汇总数据)