How should I store JSON in redis?
var redis = require("redis");
var client = redis.createClient();
js = {
"like":"macdn",
"hate":"kfc"
};
//client.set("foo_rand000000000000", "some fantastic value2");
client.set("foo_rand000000000000", JSON.stringify(js));
client.get("foo_rand000000000000", function (err, reply) {
console.log(reply.toString());
});
client.get("dislike", function (err, reply) {
if (err)
console.log(err);
else
console.log(reply.toString());
client.end();
});
console.log ('eee');
var redis = require("redis");
var client = redis.createClient();
client.get("foo_rand000000000000", function (err, reply) {
console.log(reply);
js = JSON.parse(reply);
console.log( js.like );
console.log( js.hate );
client.end();
});
console.log ('eee');
ref:
http://stackoverflow.com/questions/8986982/how-should-i-store-json-in-redis
http://stackoverflow.com/questions/5729891/redis-performance-store-json-object-as-a-string
How should I store JSON in redis?的更多相关文章
- python处理json和redis hash的坑
1.使用MySQLdb读取出来的数据是unicode字符串,如果要写入redis的hash中会变成 "{u'eth0_outFlow': 2.5, u'eth1_inFlow': 3.44} ...
- Redis初识
安装与使用 Redis-x64-3.2.100:服务端 + 客户端 redis-3.2.5:源代码 Redis Desktop Manager - v0.8.8:客户端(基于Qt5的跨平台Redis桌 ...
- Zabbix监控redis status
概述 zabbix采用Trapper方式监控redis status 原理 redis-cli info命令得到redis服务器的统计信息,脚本对信息分两部分处理: (1)# Keyspace部分为Z ...
- koa2实现session的两种方式(基于Redis 和MySQL)
一.基于MySQL的实现方式 这种方式需要安装koa-session-minimal和koa-mysql-session两个依赖. 执行 npm install koa-session-minimal ...
- Redis的Docker镜像
原文地址:https://hub.docker.com/_/redis/ Pull Command docker pull redis Short Description Redis is an op ...
- redis 学习记录
http://www.yiibai.com/redis/redis_quick_guide.html Redis 是一款依据BSD开源协议发行的高性能Key-Value存储系统(cache and s ...
- 可能这是Redis可视化工具最全的横向评测
1 命令行 不知道大家在日常操作redis时用什么可视化工具呢? 以前总觉得没有什么太好的可视化工具,于是问了一个业内朋友.对方回:你还用可视化工具?直接命令行呀,redis提供了这么多命令,操作起来 ...
- php 将查询出的数组数据存入redis
我们从数据库查询出来的数据一般为数组的形式, 而redis是不支持存入数组的, 一种解决办法是将数组转化为json数据,再将json存入redis,之后取出时再将json转化为php数组. 但将取出的 ...
- nodejs gearman redis
export NODE_PATH=/root/gearman-1.1.2/node_modulesnpm install gearmanodenpm install redis w.js var re ...
随机推荐
- day05_python_1124
---恢复内容开始--- 改l1[1:4:2]=[1:32] 对于增加个数 列表按切片取就是列表 ---恢复内容结束--- 01 昨日内容回顾 list: 增: append insert(ind ...
- Uva 12124 Uva Live 3971 - Assemble 二分, 判断器, g++不用map.size() 难度:0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- VS 中常用的一些快捷键
一.代码自动对齐 CTRL+K+F 二.撤销/反撤销 1.撤销---使用组合键“Ctrl+Z”进行撤销操作 2.反撤销---使用组合键“Ctrl+Y”进行反撤销操作 三.调用智能提示 使用组合 ...
- java①
1.MyEclipse Eclipse Idea 等 都是 开发java的IDE工具! 2.面试题: JDK: java开发工具包!(Java Development TooKit)! 是整个java ...
- 【原创】imread () 函数 读入图片的例子
Reference Links Opencv+ qt5.1 完美配置 - 脚踏实地 - 博客频道 - CSDN.NET http://blog.csdn.net/xiaojidan2011/arti ...
- [Leetcode 104]求二叉树的深度Depth of BinaryTree
[题目] Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the ...
- 理解K系列与ultra-scale的区别
总结: K系列FPGA与KU系列FPGA的主要区别,体现在: (1)工艺制程不一样,K-28nm,KU-20nm: (2)Ultra-Scale采用SSI:大容量K系列也采用SSI,SSI为了 ...
- Linux平台 获取程序依赖文件
创建sh脚本文件 =========================================================== #!/bin/sh exe=$1 #发布的程序名称des=$2 ...
- 搭建VUE项目
1.换源由于npm源服务器在国内访问速度较慢,所以一般需要更换源服务器地址npm config set registry https://registry.npm.taobao.org也可以安装cnp ...
- 浅谈generater
一.什么是generater? 1.generater 是一个工具类 2.由mybatis提供的用户生成pojo对象.mapper接口类.mapper映射文件的工具 二.使用generater 1.添 ...