当前位置:网站首页>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


边栏推荐
- Example of joint use of ros+pytoch (semantic segmentation)
- Learning notes -- principles and comparison of k-d tree and IKD tree
- 【无标题】
- 23 design models
- Kubesphere - build MySQL master-slave replication structure
- Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
- Oracle Database Introduction
- opencv
- Introduction to software engineering
- 论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
猜你喜欢

【5G NR】UE注册流程

Docker advanced learning (container data volume, MySQL installation, dockerfile)

SQL实现将多行记录合并成一行

IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库

Summary of the design and implementation of the weapon system similar to the paladin of vitality

IE browser flash back, automatically open edge browser

使用conda创建自己的深度学习环境

Support vector machine for machine learning

After the Chrome browser is updated, lodop printing cannot be called

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
随机推荐
Local rviz call and display of remote rostopic
Reinstalling the system displays "setup is applying system settings" stationary
方差迭代公式推导
[set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
Some thoughts on machine learning
Printer related problem record
2022 CISP-PTE(三)命令执行
认识弹性盒子flex
Use abp Zero builds a third-party login module (I): Principles
[untitled] 8 simplified address book
[open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
[set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)
About the difference between count (1), count (*), and count (column name)
简易密码锁
Ruoyi interface permission verification
Project summary --04
Oracle Database Introduction
IC_EDA_ALL虚拟机(丰富版):questasim、vivado、vcs、verdi、dc、pt、spyglass、icc2、synplify、INCISIVE、IC617、MMSIM、工艺库
Numerical method for solving optimal control problem (I) -- gradient method
Chapter 8. MapReduce production experience