Questions tagged [redigo]

Redigo is a Go client for the Redis database

Redigo is a Go client for the Redis database.

Features:

  • A Print-like API with support for all Redis commands.
  • Pipelining, including pipelined transactions.
  • Publish/Subscribe.
  • Connection pooling.
  • Script helper type with optimistic use of EVALSHA.
  • Helper functions for working with command replies.

Github: https://github.com/garyburd/redigo

API Reference: https://godoc.org/github.com/garyburd/redigo/redis

76 questions
9
votes
1 answer

What's an idiomatic way to reconnect to Redis subscription in Go?

I am using the redigo library to try to subscribe to a Redis channel and then handle a published message. How do I handle the case where it errors out? Here's what I came up with. Is this a good way to do it? Is there a better way? Note: this…
Drew LeSueur
  • 19,185
  • 29
  • 89
  • 106
8
votes
1 answer

Does redigo golang client support keyspace event notifications?

I am prototyping a redis client in golang using the redigo library to get notified of keyspace events. I modified the redis.conf to set the notify-keyspace-events to "KEA" to receive all events. But when I add/update/delete keys into the db using a…
anbhat
  • 427
  • 4
  • 12
7
votes
2 answers

Re-using Redigo connection instead of recreating it every time

Connecting to Redigo and manipulating data inside a function is easy like butter, but the problem comes when you have to re-use its connection, obviously for performance/practicality reasons. Doing it inside a function like this works: func main()…
user3717756
6
votes
2 answers

Get All keys From redis in go

How to get all keys of Redis in db and store it in list or array in golang using redigo? redisPool := redis.NewPool(func() (redis.Conn, error) { con, err := redis.Dial("tcp", *redisAddress) con.Do("SELECT", 0) if err != nil { …
Vinay Sawant
  • 368
  • 2
  • 7
  • 23
6
votes
2 answers

Redigo multi requests

I have previously been using this: data, err := redis.Bytes(c.Do("GET", key)) to make sure that data returned is a slice of bytes. However, I now need to add an extra command to the Redis request so I have something like…
tommyd456
  • 10,443
  • 26
  • 89
  • 163
6
votes
4 answers

Golang: Selecting DB on a RedisPool in Redigo

using redigo, I create a pool, something like so: &redis.Pool{ MaxIdle: 80, MaxActive: 12000, // max number of connections Dial: func() (redis.Conn, error) { c, err := redis.Dial("tcp", host+":"+port) if err != nil { …
Adergaard
  • 760
  • 10
  • 24
4
votes
1 answer

How can I set redis key timeout using redigo?

I'd like to add a timeout to redis key/value pair so that they expire after 10 minutes. Here is the function func setData(value string) { conn, err := redis.Dial("tcp", "localhost:6379", redis.DialDatabase(1)) if err != nil { …
Karlom
  • 13,323
  • 27
  • 72
  • 116
4
votes
2 answers

How to query Redis db from golang using redigo library

I am trying to figure out what is the best way to query Redis db for multiple keys in one command. I have seen MGET which can be used for redis-cli. But how you do that using redigo library from GOlang code. Imagine I have an array of keys and I…
Daemon1313
  • 279
  • 2
  • 5
  • 7
3
votes
2 answers

How to HSET time in Golang to redigo (Redis)?

I'm using redigo to store and retrieve data in redigo. I have a struct that contains a type definition following time. I want to store the struct Data using HSET in Redis. I have a type definition to be able to use ScanStruct by adding a function…
Oliver Becher
  • 33
  • 1
  • 4
3
votes
2 answers

How can I save and retrieve a map into redis using redigo?

I have a map like this, which I want to save/retrive from redis using redigo: animals := map[string]bool{ "cat": true, "dog": false, "fox": true, } The length of the map may vary. I tried these function: func SetHash(key string,…
Smn
  • 145
  • 1
  • 3
  • 9
3
votes
0 answers

Redis connection: Received error "dial tcp [::1]:6379: connect: connection refused" when attempting to Dial with Redigo

I'm trying to run conn, err := redis.Dial("tcp", "localhost:6379") if err != nil { log.Fatal(err) } using redis Redigo, the golang driver. I have not changed any configurations or anything. My error is: go run redisgotest.go 2019/11/19…
Trevor Jordy
  • 598
  • 1
  • 7
  • 27
3
votes
0 answers

How to fix memory leak when using connection pool?

I am using redigo with connection pool. Below is my code for setting up connection pool and the wrapper for SET call to Redis //Create a pool of client connections to Redis func newPool(MaxIdleConns int, Timeout int) *redis.Pool { return…
Utkarsh
  • 171
  • 1
  • 14
3
votes
1 answer

Some questions about Redigo and concurrency

I have read through the whole Redigo documentation which can be found here. https://godoc.org/github.com/garyburd/redigo/redis#pkg-variables Here the documentation clearly states that connections do not support concurrent calls to Send(), Flush() or…
Alex
  • 5,671
  • 9
  • 41
  • 81
3
votes
1 answer

Test a transaction (MULTI) command with redigomock

In a unittest, how can I setup redigomock to test a MULTI call with several commands included?
Charles L.
  • 5,795
  • 10
  • 40
  • 60
3
votes
2 answers

Redis how to listen changes in 1000 to 10,000 lists using golang?

I have 1000 to 10,000 keys stored in Redis, their value type is list. When a new item is added to any one of the existing lists, I need my golang program to be notified. Once notification is received I need to spawn a new goroutine and perform a…
1
2 3 4 5 6