8

Go 语言的 Redis 开发包

 2 years ago
source link: https://www.oschina.net/p/rueidis
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Go 语言的 Redis 开发包

rueidis 是一个高性能的 Go 语言的 Redis RESP3 客户端开发包,支持客户端缓存和自动流水线。

  • 用于非阻塞 redis 命令的自动管道
  • 用于阻止 redis 命令的连接池
  • 选择加入客户端缓存
  • redis cluster, pub/sub, streams, TLS, RedisJSON, RedisBloom, RediSearch, RedisGraph, RedisTimeseries
  • IDE 友好的 redis 命令生成器
  • 具有客户端缓存和乐观锁定的哈希/RedisJSON 对象映射
  • 打开遥测跟踪和指标

示例代码:

package main

import (
	"context"
	"github.com/rueian/rueidis"
)

func main() {
	c, _ := rueidis.NewClient(rueidis.ClientOption{
		InitAddress: []string{"127.0.0.1:6379"},
	})
	defer c.Close()

	ctx := context.Background()

	_ := c.Do(ctx, c.B().Set().Key("my_data").Value("my_value").Nx().Build()).Error()
	val, _ := c.Do(ctx, c.B().Get().Key("my_data").Build()).ToString()
	// val == "my_value"
}

性能测试:

Rueidis 比 go-redis 8.11.4 拥有更高的吞吐量。

Single Client

101003_fA78_12.png

Cluster Client

101010_txSY_12.png

性能测试源码: https://github.com/rueian/rueidis-benchmark

展开阅读全文

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK