问题标签 [redigo]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
80 浏览

go - 是否有任何自动增量机制用于使用 redigo 包装器将键的值存储在 redis 中?

我是编程语言的新手,只想编写一个具有良好架构的小型 Web 应用程序项目。

我通过发布请求获得了一些特定的重新调整对象。

我决定选择 redis 进行存储,因为它具有高性能,我想亲自动手。

我在这里有点困惑:

  1. 对象的性质没有用于存储的特定键,所以我提出了键自动递增的想法,但仍然坚持如何去做,因为当我研究插入模式时,它类似于:

    /li>

如您所见,我被困在关键字段中要写什么。我看到了 Redis 命令“INCR”,但这种模式似乎没有任何意义。

  1. 如果我想获取所有矩形而不考虑它们的键,connection.Do("HGETALL", "*", rectangles[])命令会帮助我获取数据库中所有矩形的数组吗?
0 投票
1 回答
791 浏览

go - 从 redis 获取结构数组时解组错误

redigo用来在redis中保存一些结构。问题是,对于同一个键,我需要附加新的结构,但是当我试图恢复它们时,我无法解组到一个数组。

即:(故意忽略错误)

如果我只附加一个结构并检索它,那么它工作正常

我试过redis.ByteSlices没有运气

0 投票
1 回答
305 浏览

go - Redigo concurrent Set gives data race

I'm running this test against my redigo functions to see if it supports massive concurrent writes, here're the code

When running the test with go test -run TestManySets /path/to/package -count 1 -v I'm getting A LOT of EOF error;

and when running the test with -race, i.e. go test -race -run TestManySets /path/to/package -count 1 -v I'm getting a lot of data race detected, anyone could kindly point out to me how I could make things right?

Below is the data race log:

And redis_test.go line 47 is where the Set happens in the code above.

0 投票
0 回答
85 浏览

docker - Redigo fetches old value from Redis Docker container

I'm developing a golang web project with Redigo to connect to a redis docker container.

While the golang web application is in running state, I've changed the value of a redis key using SET MyFlag true in redis-cli. But this is not reflecting in my webapp. When MyFlag is fetched using flag, err := redis.Bool(conn.Do("GET", "MyFlag")), it gives the old value.

But, after the webapp is restarted, the same command fetches the new value.

conn is retrieved from a redis connection pool. This is the configuration for redis pool

#xA;

Is this the issue of caching in Redis/Redigo/Docker ?

0 投票
1 回答
793 浏览

go - Redigo:如何使用 Golang 从 Redis 获取键值映射?

假设我的 Redis 中有这组键:

我需要使用 Redigo 在 Golang 中返回包含所有这些键和值的映射。输出将类似于map[uint64]string带有此键值的 a:

如果我这样做,Scan我可以获得与模式匹配的所有键agent_*,也许然后我可以MGET使用所有这些键来获取值,但是我如何以简单的方式链接这些键和值?

没有一个库函数不仅可以获取与模式匹配的键,还可以获取值,所以我可以用它返回一个映射?

我现在正在使用redigo,但我也在研究go-redis是否有更简单的方法来实现这一点,我愿意考虑其他选择。

谢谢!

0 投票
0 回答
1459 浏览

database - Redis 连接:尝试使用 Redigo 拨号时收到错误“dial tcp [::1]:6379: connect: connection denied”

我正在尝试运行

使用 golang 驱动程序 redis Redigo。我没有更改任何配置或任何东西。我的错误是:

0 投票
2 回答
767 浏览

go - Error - redigo.Scan: Cannot convert from Redis bulk string to *string

I have a struct like that

Values ​​are placed in redis with HMSET command. (values ​​can be nil)

Now I'm trying to scan values ​​into a structure:

But I get an error

redigo.Scan: cannot assign to dest 0: cannot convert from Redis bulk string to *string

Please tell me what I'm doing wrong?

0 投票
1 回答
359 浏览

string - 使用 redigo 读取作为 JSON 字符串的 Redis 键值

我正在尝试在 Go 中阅读 Redis Key-val。键是字符串,值是 JSON 字符串。例如-键=

和值作为 Json 字符串 =

在 Go 中阅读时出现以下错误

这是我的代码:

0 投票
2 回答
2243 浏览

go - 如何使用 redigo 将地图保存并检索到 redis 中?

我有一张这样的地图,我想使用 redigo 从 redis 中保存/检索它:

地图的长度可能会有所不同。

我尝试了这些功能:

但无法GetHash正确制作。我检查了文档示例,但没有帮助。因此,感谢您对提供工作示例的帮助。

0 投票
0 回答
268 浏览

go - 使用 redigo 评估脚本时如何设置超时?

我正在使用 redigo (github.com/gomodule/redigo/redis) 来评估 redis 上的一些 lua 脚本。

但是,我阅读了相关的 GoDoc,在使用 redis.Script 类型评估 lua 脚本时找不到任何设置超时的方法。Script.Do 方法调用 conn.Do 方法,该方法不设置超时。在评估 lua 脚本时,有什么方法可以用来设置超时限制吗?