redigo有点像hiredis,只提供了最基本的连接和执行命令接口。

找到个不错的redis库:

https://github.com/go-redis/redis

func ExampleNewClient() {
    client := redis.NewClient(&redis.Options{
        Addr:     "localhost:6379",
        Password: "", // no password set
        DB:       0,  // use default DB
    })     pong, err := client.Ping().Result()
    fmt.Println(pong, err)
    // Output: PONG <nil>
} func ExampleClient() {
    err := client.Set("key", "value", 0).Err()
    if err != nil {
        panic(err)
    }     val, err := client.Get("key").Result()
    if err != nil {
        panic(err)
    }
    fmt.Println("key", val)     val2, err := client.Get("key2").Result()
    if err == redis.Nil {
        fmt.Println("key2 does not exists")
    } else if err != nil {
        panic(err)
    } else {
        fmt.Println("key2", val2)
    }
    // Output: key value
    // key2 does not exists
}

  

后端程序员之路 55、go redis的更多相关文章

  1. 后端程序员之路 43、Redis list

    Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...

  2. 后端程序员之路 46、Redis Sentinel

    Sentinel - Redis 命令参考http://doc.redisfans.com/topic/sentinel.html#sentinel-api Guidelines for Redis ...

  3. 后端程序员之路 44、Redis结合protobuf

    protobuf序列化速度不错,在往Redis里存对象时,用protobuf序列化可以节省内存,省去写序列化反序列化代码的工作. google protocol buffer 与 redis 结合使用 ...

  4. 后端程序员之路 25、Redis Cluster

    官方教程和功能介绍: REDIS cluster-tutorial -- Redis中文资料站 -- Redis中国用户组(CRUG)http://www.redis.cn/topics/cluste ...

  5. 后端程序员之路 24、Redis hiredis

    Redishttps://redis.io/ Redis快速入门 - Redis教程http://www.yiibai.com/redis/redis_quick_guide.html wget ht ...

  6. 后端程序员之路 59、go uiprogress

    gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...

  7. 后端程序员之路 49、SSDB

    正如Redis似乎是为替换memcached一样,SSSB是一个国人开发的旨在替换Redis的kv数据库. SSDB - 高性能的支持丰富数据结构的 NoSQL 数据库, 替代 Redishttp:/ ...

  8. 后端程序员之路 48、memcached

    memcached - a distributed memory object caching systemhttp://memcached.org/ Memcached 教程 | 菜鸟教程http: ...

  9. 后端程序员之路 27、LogStash

    访谈与书评:<LogStash,使日志管理更简单>http://www.infoq.com/cn/articles/review-the-logstash-book/ [Logstash] ...

随机推荐

  1. Codeforces Round #533 (Div. 2) A. Salem and Sticks(枚举)

    #include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int a[n];for(in ...

  2. Codeforces Round #646 (Div. 2) B. Subsequence Hate(前缀和)

    题目链接:https://codeforces.com/contest/1363/problem/B 题意 可以将 $01$ 串中的 $0$ 变为 $1$.$1$ 变为 $0$,问至少需要变换多少字符 ...

  3. P1280 尼克的任务(DP)

    题目描述 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成. 尼克的一个工作日为N分钟,从第一分钟开始 ...

  4. Alice's mooncake shop HDU - 4122 单调队列

    题意: 有n个订单和可以在m小时内制作月饼,制作月饼不考虑时间(即,你可以在一个时刻在所有需要的月饼都做完) 接下来是n个订单的信息:需要在mon月,d日,year年,h小时交付订单r个月饼 接下来一 ...

  5. Leetcode(9)-回文数

    判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向 ...

  6. 系统扩展与 macOS 不兼容

    系统扩展与 macOS 不兼容 某些系统扩展与当前版本的 macOS 不兼容或将与后续 macOS 版本不兼容 https://support.apple.com/zh-cn/HT210999 ref ...

  7. Emoji of github & twitter

    Emoji cheat sheet http://www.emoji-cheat-sheet.com/ https://github.com/xgqfrms/emoji-cheat-sheet.com ...

  8. linux 必备 学习 资源 汇总 大全!

    Linux https://www.linux.com/ https://youtu.be/CE4WeUNFX2g https://www.youtube.com/watch?v=JzsLkbwi1L ...

  9. MobX All In One

    MobX All In One Simple, scalable state management. https://mobx.js.org/README.html https://github.co ...

  10. JavaScript & Atomics

    JavaScript & Atomics Atomics 对象提供了一组静态方法对 SharedArrayBuffer 和 ArrayBuffer 对象进行原子操作. Atomics.add ...