当前位置:网站首页>Golang operation redis: write and read kV data
Golang operation redis: write and read kV data
2022-07-03 06:38:00 【Learn programming notes】
Code
package main
import (
"fmt"
"github.com/garyburd/redigo/redis" // introduce redis package
)
func main() {
// adopt go towards redis Write data and read data
//1. link to redis
conn, err := redis.Dial("tcp", "127.0.0.1:6379")
if err != nil {
fmt.Println("redis.Dial err=", err)
return
}
defer conn.Close() // close ..
//2. adopt go towards redis Write data string [key-val]
_, err = conn.Do("Set", "name", "tomjerry Cat and cat ")
if err != nil {
fmt.Println("set err=", err)
return
}
//3. adopt go towards redis Reading data string [key-val]
r, err := redis.String(conn.Do("Get", "name"))
if err != nil {
fmt.Println("set err=", err)
return
}
// Because back r yes interface{}
// because name The corresponding value is string , So we need to switch
//nameString := r.(string)
fmt.Println(" operation ok ", r)
}
result
边栏推荐
- Various usages of MySQL backup database to create table select and how many days are left
- UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
- In depth analysis of kubernetes controller runtime
- Reinstalling the system displays "setup is applying system settings" stationary
- Pytest attempts to execute the test case without skipping, but the case shows that it is all skipped
- SQL implementation merges multiple rows of records into one row
- 这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
- 剖析虚幻渲染体系(16)- 图形驱动的秘密
- 堆排序和优先队列
- Create your own deep learning environment with CONDA
猜你喜欢
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
Chapter 8. MapReduce production experience
Create your own deep learning environment with CONDA
Mysql
Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide
Selenium ide installation recording and local project maintenance
DBNet:具有可微分二值化的实时场景文本检测
. Net program configuration file operation (INI, CFG, config)
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
2022年华东师范大学计科考研复试机试题-详细题解
随机推荐
Push box games C #
pytorch练习小项目
In depth analysis of kubernetes controller runtime
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
修改MySQL密码
【无标题】8 简易版通讯录
Chapter 8. MapReduce production experience
The dynamic analysis and calculation of expressions are really delicious for flee
DNS forward query:
UTC时间、GMT时间、CST时间
YOLOV3学习笔记
golang操作redis:写入、读取kv数据
Learning notes -- principles and comparison of k-d tree and IKD tree
[untitled] 8 simplified address book
Openresty best practices
vmware虚拟机C盘扩容
A letter to graduating college students
使用conda创建自己的深度学习环境
The difference between CONDA and pip
Important knowledge points of redis