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


边栏推荐
- Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
- Operation principle of lua on C: Foundation
- Support vector machine for machine learning
- [open source project recommendation colugomum] this group of undergraduates open source retail industry solutions based on the domestic deep learning framework paddlepadddle
- 堆排序和优先队列
- Use @data in Lombok to simplify entity class code
- DNS forward query:
- Pdf files can only print out the first page
- Unittest attempt
- Luogu problem list: [mathematics 1] basic mathematics problems
猜你喜欢

机器学习 | 简单但是能提升模型效果的特征标准化方法(RobustScaler、MinMaxScaler、StandardScaler 比较和解析)
![[5g NR] UE registration process](/img/e3/f881d51fba03010de8c45ea480f3f0.png)
[5g NR] UE registration process

Selenium ide installation recording and local project maintenance

YOLOV3学习笔记

Selenium - by changing the window size, the width, height and length of different models will be different

Scripy learning

scroll-view指定滚动元素的起始位置

论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》

Redis cluster creation, capacity expansion and capacity reduction

輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷
随机推荐
【5G NR】UE注册流程
【类和对象】深入浅出类和对象
Cannot get value with @value, null
ruoyi接口权限校验
Opencv mouse and keyboard events
Derivation of variance iteration formula
Difference between shortest path and minimum spanning tree
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
JMeter linked database
(翻译)异步编程:Async/Await在ASP.NET中的介绍
Kubesphere - build Nacos cluster
Read blog type data from mysql, Chinese garbled code - solved
使用conda创建自己的深度学习环境
Oracle Database Introduction
这两种驱蚊成份对宝宝有害,有宝宝的家庭,选购驱蚊产品要注意
. Net program configuration file operation (INI, CFG, config)
Introduction to software engineering
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
2022 cisp-pte (III) command execution
The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list