Golang redigo hmset hset 问题
最近公司项目,换到了golang 下面来开发,遇到了redis存储链表的问题,困扰了我好几天,后面静下心来,好好读了一下源码,发现官方的例子,最终还是羊毛出在羊身上
c, err := dial()
if err != nil {
panic(err)
}
defer c.Close() var p1, p2 struct {
Title string `redis:"title"`
Author string `redis:"author"`
Body string `redis:"body"`
} p1.Title = "Example"
p1.Author = "Gary"
p1.Body = "Hello" if _, err := c.Do("HMSET", redis.Args{}.Add("id1").AddFlat(&p1)...); err != nil {
panic(err)
} m := map[string]string{
"title": "Example2",
"author": "Steve",
"body": "Map",
} if _, err := c.Do("HMSET", redis.Args{}.Add("id2").AddFlat(m)...); err != nil {
panic(err)
} for _, id := range []string{"id1", "id2"} { v, err := redis.Values(c.Do("HGETALL", id))
if err != nil {
panic(err)
} if err := redis.ScanStruct(v, &p2); err != nil {
panic(err)
} fmt.Printf("%+v\n", p2)
}
Golang redigo hmset hset 问题的更多相关文章
- Go Redis 开发
redigo库来实现redis的操作:https://github.com/gomodule/redigo Redis常用操作 示例代码: package main import ( "gi ...
- 在 CentOS7 之部署 Redis3
CentOS7 之 Redis3 学习笔记 1 Redis 官网: http://www.redis.io/ 2 Redis 的下载地址: http://download.redis.io/relea ...
- PHP Redis
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Myredis { //redis所 ...
- Redis命令大全&中文解释&在线测试命令工具&在线中文文档
在线测试命令地址:http://try.redis.io/ 官方文档:http://redis.io/commands http://redis.io/documentation Redis 命令参考 ...
- Awesome Go
A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...
- Redis最有用的中文资源,你值得拥有
只是为了记录资源地址,最好直接访问doc.redisfans.com更美观 Redis 命令参考 本文档是 Redis Command Reference 和 Redis Documentation ...
- openresty(完整版)Lua拦截请求与响应信息日志收集及基于cjson和redis动态路径以及Prometheus监控(转)
直接上文件 nginx.conf #运行用户和组,缺省为nobody,若改为别的用户和组,则需要先创建用户和组 #user wls81 wls; #开启进程数,一般与CPU核数等同 worker_pr ...
- Go 语言相关的优秀框架,库及软件列表
If you see a package or project here that is no longer maintained or is not a good fit, please submi ...
- phpredis命令
<?php //redis //检查一个扩展是否已经加载.大小写不敏感. if (!function_exists('redis')) { echo '不支持 redis'; return ; ...
随机推荐
- 11g添加asm
1.创建组 2.创建grid用户 3.用grid安装Gride Infrastructure软件 4.执行root.sh[root@ora11g softdb]# /u01/app/11.2.0/gr ...
- C语言中如何将二维数组作为函数的参数传递
今天写程序的时候要用到二维数组作参数传给一个函数,我发现将二维数组作参数进行传递还不是想象得那么简单里,但是最后我也解决了遇到的问题,所以这篇文章主要介绍如何处理二维数组当作参数传递的情况,希望大家不 ...
- poj 1816 (Trie + dfs)
题目链接:http://poj.org/problem?id=1816 思路:建好一颗Trie树,由于给定的模式串可能会重复,在原来定义的结构体中需要增加一个vector用来记录那些以该节点为结尾的字 ...
- 有关servlet初学者的资源和建议
四天来学习servlet是很痛苦的经历,其实可以不必要这么痛苦,关键是一定要学会冷静的分析问题与解决问题,要不言学习也没有那么多的乐趣.初学java刚满15天. 首先对于资源来说建议先读一点点的PPT ...
- C++ 拷贝构造函数 和 六大函数
1. C++什么时候会调用 拷贝构造函数? a.一个对象作为函数参数,以值传递的方式传入函数体: b.一个对象作为函数返回值,以值传递的方式从函数返回:(实际使用时,会被编译器优化掉) c.一个对象 ...
- centos7安装redis3.2.5
安装redis 1官方介绍 Installation Download, extract and compile Redis with: $ wget http://download.redis.io ...
- error: bad symbolic reference. A signature in HiveContext.class refers to term hive
在spark-shell中执行val sqlContext = new org.apache.spark.sql.hive.HiveContext(sc)报错: error: bad symbolic ...
- BurpSuite的使用总结
BurpSuite BurpSuite 是一款使用Java编写的,用于Web安全审计与扫描套件.它集成了诸多实用的小工具以完成http请求的转发/修改/扫描等,同时这些小工具之间还可以 互相协作,在B ...
- Mongdb使用客户端
安装Robomongo图形化管理工具 Robomongo是一个基于 Shell 的跨平台开源 MongoDB 管理工具.嵌入了 JavaScript 引擎和 MongoDB mogo . 只要你会使用 ...
- hdu4968
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4968 说是考dp,但是我没出来dp在哪,可能贪心思想更多一些吧. AC代码: #inclu ...