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 ; ...
随机推荐
- HDU3359 Kind of a Blur(高斯消元)
建立方程后消元 #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring& ...
- hdu 3709 数位dp
数位dp,有了进一步的了解,模板也可以优化一下了 题意:找出区间内平衡数的个数,所谓的平衡数,就是以这个数字的某一位为支点,另外两边的数字大小乘以力矩之和相等,即为平衡数例如4139,以3为支点4*2 ...
- 时间编程,王明学learn
时间编程 一.时间类型 Coordinated Universal Time(UTC):世界标准时间,也就是大家所熟知的格林威治标准时间(Greenwich Mean Time,GMT) Calend ...
- C 和 C++ 混合代码 cmath编译出错
最近在网上下载了 Triangle 库,准备在程序中调用来三角化生成网格,但出现了很多错误,如下: 1> triangle.c1>d:\program files\visualstudi ...
- 数字信号处理实验(一)——DTFT
1.MATLAB自编绘图函数 function [] = signal_write(X,w,flag) % X:数据 % w:频率向量 magX=abs(X);angX=angle(X); realX ...
- flex_宽度补全
宽度40px,另一个的补全宽度: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...
- Loadrunner中关联的作用:
获取并保存变化的request值{1.sessionid;2.获取上个请求的响应值,用于下个请求参数} 作为检查点 脚本调试工具
- JS Number对象
数字属性 MAX_VALUE MIN_VALUE NEGATIVE_INFINITY POSITIVE_INFINITY NaN prototype constructor 数字方法 toExpone ...
- 廖雪峰js教程笔记5 Arrow Function(箭头函数)
为什么叫Arrow Function?因为它的定义用的就是一个箭头: x => x * x 上面的箭头函数相当于: function (x) { return x * x; } 箭头函数 阅读: ...
- 使用jQuery要注意的问题
1. $.find()与$.children()的区别 有如下HTML片段: 复制代码代码如下: <div id="div_four"> <input id=&q ...