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?的更多相关文章

  1. python处理json和redis hash的坑

    1.使用MySQLdb读取出来的数据是unicode字符串,如果要写入redis的hash中会变成 "{u'eth0_outFlow': 2.5, u'eth1_inFlow': 3.44} ...

  2. Redis初识

    安装与使用 Redis-x64-3.2.100:服务端 + 客户端 redis-3.2.5:源代码 Redis Desktop Manager - v0.8.8:客户端(基于Qt5的跨平台Redis桌 ...

  3. Zabbix监控redis status

    概述 zabbix采用Trapper方式监控redis status 原理 redis-cli info命令得到redis服务器的统计信息,脚本对信息分两部分处理: (1)# Keyspace部分为Z ...

  4. koa2实现session的两种方式(基于Redis 和MySQL)

    一.基于MySQL的实现方式 这种方式需要安装koa-session-minimal和koa-mysql-session两个依赖. 执行 npm install koa-session-minimal ...

  5. Redis的Docker镜像

    原文地址:https://hub.docker.com/_/redis/ Pull Command docker pull redis Short Description Redis is an op ...

  6. redis 学习记录

    http://www.yiibai.com/redis/redis_quick_guide.html Redis 是一款依据BSD开源协议发行的高性能Key-Value存储系统(cache and s ...

  7. 可能这是Redis可视化工具最全的横向评测

    1 命令行 不知道大家在日常操作redis时用什么可视化工具呢? 以前总觉得没有什么太好的可视化工具,于是问了一个业内朋友.对方回:你还用可视化工具?直接命令行呀,redis提供了这么多命令,操作起来 ...

  8. php 将查询出的数组数据存入redis

    我们从数据库查询出来的数据一般为数组的形式, 而redis是不支持存入数组的, 一种解决办法是将数组转化为json数据,再将json存入redis,之后取出时再将json转化为php数组. 但将取出的 ...

  9. nodejs gearman redis

    export NODE_PATH=/root/gearman-1.1.2/node_modulesnpm install gearmanodenpm install redis w.js var re ...

随机推荐

  1. am335x system upgrade uboot ethernet(二)

    系统可以通过SD卡引道之后,为了之后了调试方便 通过查看网卡的硬件设计 正常来说需要注意的有如下几点: 1) 网口 的接线方式: RMII 2) 网口的PHY地址两张网口,这里我们只需先初始化一张网卡 ...

  2. fzu1977

    题解: 和前两题差不多 只不过变成了有些一定走,有些不一定 代码: #include<cstdio> #include<cmath> #include<algorithm ...

  3. 稀疏 部分 Checkout

    To easily select only the items you want for the checkout and force the resulting working copy to ke ...

  4. 自动化创建tornado项目

    tornado目录结构: index.py 入口文件 app app目录 |___ __init__.py 初始化脚本 |___ templates  模板目录 |        |___ index ...

  5. struts请求参数注入的三种方式

    .请求参数的注入 在Struts2框架中,表单的提交的数据会自动注入到与Action对象相对应的属性.它与Spring框架中的IoC的注入原理相同,通过Action对象为属性提供setter方法注入 ...

  6. LSTM-自然语言建模

    说到自然语言,我就会想到朴素贝叶斯,贝叶斯核心就是条件概率,而且大多数自然语言处理的思想也就是条件概率. 所以我用预测一个句子出现的概率为例,阐述一下自然语言处理的思想. 处理思想-概率 句子,就是单 ...

  7. Linux文件系统命令 mv

    命令名:mv 功能:移动一个文件,从一个位置到另外一个位置. 用法:mv source_dir dist_dir eg: renjg@renjg-HP-Compaq-Pro--MT:/var/tmp$ ...

  8. L275 Climate Change Is Having a Major Impact on Global Health

    Climate Change Is Having a Major Impact on Global Health A devastating heat wave swept across Europe ...

  9. ob_gzhandler — ob_start callback function to gzip output buffer

    <?php ob_start("ob_gzhandler"); ?><html><body><p>This should be a  ...

  10. ubantu 常用命令

    1.显示日期与时间的命令:date 2.显示日历的命令:cal 3.简单好用的计算器:bc 4.热键“命令补全或文件补齐”:Tab 5.热键“中断目前程序”:Ctrl+C 6.热键“键盘输入结束(En ...