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. 替代iframe

    1.jq中 通过JQuery的load()方法动态加载页面. $( "#result" ).load( "app/test.html" ); 2.vue.rea ...

  2. Date和 Calendar

    import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...

  3. 稀疏 部分 Checkout

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

  4. TCP/IP协议 计算机间的通讯,传输、socket 传输通道

    #! /usr/bin/env python3 # -*- coding:utf-8 -*- #TCP/IP简介 #为了把全世界的所有不同类型的计算机都连接起来,就必须规定一套全球通用的协议,为了实现 ...

  5. 深入理解java虚拟机---虚拟机工具jmap(十六)

    原文: https://www.cnblogs.com/myna/p/7573843.html jmap JVM Memory Map命令用于生成heap dump文件,如果不使用这个命令,还可以使用 ...

  6. linux,windows下日志文件查找关键词

    1.查找 /apps/tomcat/tomcat3/apache-tomcat-7.0.69/logs 目录下已.txt结尾的文件,在文件中搜索关键字 IfcmpEcrService并打印行号 /lo ...

  7. L299 EST 科技英语翻译-美学取向 (下)

    4. Ordering(有序美) DescriptiveExpositoryArgumentative Chinese: end focus 句尾焦点English: beginning focus ...

  8. delete CDU

    function DeletePDU(){ global $person; $this->MakeSafe(); // Do not attempt anything else if the l ...

  9. subprocess(子进程模块)

    subprocess: 子进程模块 一个正在运行的程序叫做进程 一个进程 开启了另一个进程 这个被开启的程序叫做子ka进程 ###########################在cmd中执行#### ...

  10. ubantu清理垃圾文件操作

    安装的ubuntu 18.01 , 随着使用的时间变长,陆陆续续使用了不少的软件, 更新了不少的软件包. 导致了现在ubuntu 系统反应速度严重下降. 下面是几种清理linux系统下冗余垃圾的命令, ...