boulder/vendor/github.com/redis/go-redis/v9
dependabot[bot] c881ce1f94
build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079)
Bumps [github.com/redis/go-redis/v9](https://github.com/redis/go-redis)
from 9.5.3 to 9.7.3.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/redis/go-redis/releases">github.com/redis/go-redis/v9's
releases</a>.</em></p>
<blockquote>
<h2>v9.7.3</h2>
<h2>What's Changed</h2>
<ul>
<li>fix: handle network error on SETINFO (<a
href="https://redirect.github.com/redis/go-redis/issues/3295">#3295</a>)
(<a
href="https://github.com/redis/go-redis/security/advisories/GHSA-92cp-5422-2mw7">CVE-2025-29923</a>)</li>
<li>Deprecating misspelled <code>DisableIndentity</code> flag in the
client options.</li>
<li>Introducing <code>DisableIdentity</code> flag in the client
options.</li>
<li>Updating the documentation related to the new flag and the one that
was deprecated.</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/redis/go-redis/compare/v9.7.1...v9.7.3">https://github.com/redis/go-redis/compare/v9.7.1...v9.7.3</a></p>
<h2>v9.7.1</h2>
<h1>Changes</h1>
<ul>
<li>Recognize byte slice for key argument in cluster client hash slot
computation (<a
href="https://redirect.github.com/redis/go-redis/issues/3049">#3049</a>)</li>
<li>fix(search&amp;aggregate):fix error overwrite and typo <a
href="https://redirect.github.com/redis/go-redis/issues/3220">#3220</a>
(<a
href="https://redirect.github.com/redis/go-redis/issues/3224">#3224</a>)</li>
<li>fix: linter configuration (<a
href="https://redirect.github.com/redis/go-redis/issues/3279">#3279</a>)</li>
<li>fix(search): if ft.aggregate use limit when limitoffset is zero (<a
href="https://redirect.github.com/redis/go-redis/issues/3275">#3275</a>)</li>
<li>Reinstate read-only lock on hooks access in dialHook to fix data
race (<a
href="https://redirect.github.com/redis/go-redis/issues/3225">#3225</a>)</li>
<li>fix: flaky ClientKillByFilter test (<a
href="https://redirect.github.com/redis/go-redis/issues/3268">#3268</a>)</li>
<li>chore: fix some comments (<a
href="https://redirect.github.com/redis/go-redis/issues/3226">#3226</a>)</li>
<li>fix(aggregate, search): ft.aggregate bugfixes (<a
href="https://redirect.github.com/redis/go-redis/issues/3263">#3263</a>)</li>
<li>fix: add unstableresp3 to cluster client (<a
href="https://redirect.github.com/redis/go-redis/issues/3266">#3266</a>)</li>
<li>Fix race condition in clusterNodes.Addrs() (<a
href="https://redirect.github.com/redis/go-redis/issues/3219">#3219</a>)</li>
<li>SortByWithCount FTSearchOptions fix (<a
href="https://redirect.github.com/redis/go-redis/issues/3201">#3201</a>)</li>
<li>Eliminate redundant dial mutex causing unbounded connection queue
contention (<a
href="https://redirect.github.com/redis/go-redis/issues/3088">#3088</a>)</li>
<li>Add guidance on unstable RESP3 support for RediSearch commands to
README (<a
href="https://redirect.github.com/redis/go-redis/issues/3177">#3177</a>)</li>
</ul>
<h2>🚀 New Features</h2>
<ul>
<li>Add guidance on unstable RESP3 support for RediSearch commands to
README (<a
href="https://redirect.github.com/redis/go-redis/issues/3177">#3177</a>)</li>
</ul>
<h2>🐛 Bug Fixes</h2>
<ul>
<li>fix(search): if ft.aggregate use limit when limitoffset is zero (<a
href="https://redirect.github.com/redis/go-redis/issues/3275">#3275</a>)</li>
<li>fix: add unstableresp3 to cluster client (<a
href="https://redirect.github.com/redis/go-redis/issues/3266">#3266</a>)</li>
<li>fix(aggregate, search): ft.aggregate bugfixes (<a
href="https://redirect.github.com/redis/go-redis/issues/3263">#3263</a>)</li>
<li>SortByWithCount FTSearchOptions fix (<a
href="https://redirect.github.com/redis/go-redis/issues/3201">#3201</a>)</li>
<li>Recognize byte slice for key argument in cluster client hash slot
computation (<a
href="https://redirect.github.com/redis/go-redis/issues/3049">#3049</a>)</li>
</ul>
<h2>Contributors</h2>
<p>We'd like to thank all the contributors who worked on this
release!</p>
<p><a
href="https://github.com/ofekshenawa"><code>@​ofekshenawa</code></a>, <a
href="https://github.com/Cgol9"><code>@​Cgol9</code></a>, <a
href="https://github.com/LINKIWI"><code>@​LINKIWI</code></a>, <a
href="https://github.com/shawnwgit"><code>@​shawnwgit</code></a>, <a
href="https://github.com/zhuhaicity"><code>@​zhuhaicity</code></a>, <a
href="https://github.com/bitsark"><code>@​bitsark</code></a>, <a
href="https://github.com/vladvildanov"><code>@​vladvildanov</code></a>,
<a href="https://github.com/ndyakov"><code>@​ndyakov</code></a></p>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/redis/go-redis/compare/v9.7.0...v9.7.1">https://github.com/redis/go-redis/compare/v9.7.0...v9.7.1</a></p>
<h2>9.7.0</h2>
<h1>Changes</h1>
<h2>🚀 New Features</h2>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="a29d91d9ca"><code>a29d91d</code></a>
release 9.7.3, retract 9.7.2 (<a
href="https://redirect.github.com/redis/go-redis/issues/3314">#3314</a>)</li>
<li><a
href="ce3034c7b3"><code>ce3034c</code></a>
bump version to 9.7.2</li>
<li><a
href="0af2b32f93"><code>0af2b32</code></a>
fix: handle network error on SETINFO (<a
href="https://redirect.github.com/redis/go-redis/issues/3295">#3295</a>)
(CVE-2025-29923)</li>
<li><a
href="3d041a1dd6"><code>3d041a1</code></a>
release: 9.7.1 patch (<a
href="https://redirect.github.com/redis/go-redis/issues/3278">#3278</a>)</li>
<li><a
href="ed37c33a90"><code>ed37c33</code></a>
Updated package version [9.7] (<a
href="https://redirect.github.com/redis/go-redis/issues/3159">#3159</a>)</li>
<li><a
href="135f8e3b12"><code>135f8e3</code></a>
Fix field name spellings (<a
href="https://redirect.github.com/redis/go-redis/issues/3132">#3132</a>)
(<a
href="https://redirect.github.com/redis/go-redis/issues/3156">#3156</a>)</li>
<li><a
href="ac2e91d9d9"><code>ac2e91d</code></a>
Support Json with Resp 2 (<a
href="https://redirect.github.com/redis/go-redis/issues/3146">#3146</a>)
(<a
href="https://redirect.github.com/redis/go-redis/issues/3155">#3155</a>)</li>
<li><a
href="ec680aec14"><code>ec680ae</code></a>
Remove direct read from TLS underlying conn (<a
href="https://redirect.github.com/redis/go-redis/issues/3138">#3138</a>)
(<a
href="https://redirect.github.com/redis/go-redis/issues/3154">#3154</a>)</li>
<li><a
href="ad131f49b0"><code>ad131f4</code></a>
Updated package version (<a
href="https://redirect.github.com/redis/go-redis/issues/3134">#3134</a>)</li>
<li><a
href="d9eeed131a"><code>d9eeed1</code></a>
Fix Flaky Test: should handle FTAggregate with Unstable RESP3 Search
Module a...</li>
<li>Additional commits viewable in <a
href="https://github.com/redis/go-redis/compare/v9.5.3...v9.7.3">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/redis/go-redis/v9&package-manager=go_modules&previous-version=9.5.3&new-version=9.7.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-26 14:56:48 -07:00
..
internal build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
.gitignore build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
.golangci.yml build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
.prettierrc.yml dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
CHANGELOG.md Add opentelemetry tracing for Redis (#7598) 2024-08-08 11:12:58 -04:00
CONTRIBUTING.md build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
LICENSE dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
Makefile build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
README.md build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
RELEASING.md dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
acl_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
bitmap_commands.go Add opentelemetry tracing for Redis (#7598) 2024-08-08 11:12:58 -04:00
cluster_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
command.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
doc.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
error.go Add opentelemetry tracing for Redis (#7598) 2024-08-08 11:12:58 -04:00
gears_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
generic_commands.go Add opentelemetry tracing for Redis (#7598) 2024-08-08 11:12:58 -04:00
geo_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
hash_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
hyperloglog_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
iterator.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
json.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
list_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
options.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
osscluster.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
osscluster_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
pipeline.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
probabilistic.go build(deps): bump github.com/redis/go-redis/v9 from 9.2.1 to 9.3.0 (#7186) 2023-12-12 10:09:12 -05:00
pubsub.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
pubsub_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
redis.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
result.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
ring.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
script.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
scripting_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
search_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
sentinel.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
set_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
sortedset_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
stream_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
string_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.1.0 to 9.2.1 (#7107) 2023-10-27 09:12:54 -07:00
timeseries_commands.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
tx.go dependencies: Update go-redis from v8 to v9 (#7041) 2023-08-22 13:06:25 -04:00
universal.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00
version.go build(deps): bump github.com/redis/go-redis/v9 from 9.5.3 to 9.7.3 (#8079) 2025-03-26 14:56:48 -07:00

README.md

Redis client for Go

build workflow PkgGoDev Documentation codecov Chat

go-redis is brought to you by uptrace/uptrace. Uptrace is an open-source APM tool that supports distributed tracing, metrics, and logs. You can use it to monitor applications and set up automatic alerts to receive notifications via email, Slack, Telegram, and others.

See OpenTelemetry example which demonstrates how you can use Uptrace to monitor go-redis.

How do I Redis?

Learn for free at Redis University

Build faster with the Redis Launchpad

Try the Redis Cloud

Dive in developer tutorials

Join the Redis community

Work at Redis

Documentation

Resources

Ecosystem

This client also works with Kvrocks, a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.

Features

Installation

go-redis supports 2 last Go versions and requires a Go version with modules support. So make sure to initialize a Go module:

go mod init github.com/my/repo

Then install go-redis/v9:

go get github.com/redis/go-redis/v9

Quickstart

import (
    "context"
    "fmt"

    "github.com/redis/go-redis/v9"
)

var ctx = context.Background()

func ExampleClient() {
    rdb := redis.NewClient(&redis.Options{
        Addr:     "localhost:6379",
        Password: "", // no password set
        DB:       0,  // use default DB
    })

    err := rdb.Set(ctx, "key", "value", 0).Err()
    if err != nil {
        panic(err)
    }

    val, err := rdb.Get(ctx, "key").Result()
    if err != nil {
        panic(err)
    }
    fmt.Println("key", val)

    val2, err := rdb.Get(ctx, "key2").Result()
    if err == redis.Nil {
        fmt.Println("key2 does not exist")
    } else if err != nil {
        panic(err)
    } else {
        fmt.Println("key2", val2)
    }
    // Output: key value
    // key2 does not exist
}

The above can be modified to specify the version of the RESP protocol by adding the protocol option to the Options struct:

    rdb := redis.NewClient(&redis.Options{
        Addr:     "localhost:6379",
        Password: "", // no password set
        DB:       0,  // use default DB
        Protocol: 3, // specify 2 for RESP 2 or 3 for RESP 3
    })

Connecting via a redis url

go-redis also supports connecting via the redis uri specification. The example below demonstrates how the connection can easily be configured using a string, adhering to this specification.

import (
    "github.com/redis/go-redis/v9"
)

func ExampleClient() *redis.Client {
    url := "redis://user:password@localhost:6379/0?protocol=3"
    opts, err := redis.ParseURL(url)
    if err != nil {
        panic(err)
    }

    return redis.NewClient(opts)
}

Advanced Configuration

go-redis supports extending the client identification phase to allow projects to send their own custom client identification.

Default Client Identification

By default, go-redis automatically sends the client library name and version during the connection process. This feature is available in redis-server as of version 7.2. As a result, the command is "fire and forget", meaning it should fail silently, in the case that the redis server does not support this feature.

Disabling Identity Verification

When connection identity verification is not required or needs to be explicitly disabled, a DisableIdentity configuration option exists. Initially there was a typo and the option was named DisableIndentity instead of DisableIdentity. The misspelled option is marked as Deprecated and will be removed in V10 of this library. Although both options will work at the moment, the correct option is DisableIdentity. The deprecated option will be removed in V10 of this library, so please use the correct option name to avoid any issues.

To disable verification, set the DisableIdentity option to true in the Redis client options:

rdb := redis.NewClient(&redis.Options{
    Addr:            "localhost:6379",
    Password:        "",
    DB:              0,
    DisableIdentity: true, // Disable set-info on connect
})

Unstable RESP3 Structures for RediSearch Commands

When integrating Redis with application functionalities using RESP3, it's important to note that some response structures aren't final yet. This is especially true for more complex structures like search and query results. We recommend using RESP2 when using the search and query capabilities, but we plan to stabilize the RESP3-based API-s in the coming versions. You can find more guidance in the upcoming release notes.

To enable unstable RESP3, set the option in your client configuration:

redis.NewClient(&redis.Options{
			UnstableResp3: true,
		})

Note: When UnstableResp3 mode is enabled, it's necessary to use RawResult() and RawVal() to retrieve a raw data. Since, raw response is the only option for unstable search commands Val() and Result() calls wouldn't have any affect on them:

res1, err := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{}).RawResult()
val1 := client.FTSearchWithArgs(ctx, "txt", "foo bar", &redis.FTSearchOptions{}).RawVal()

Contributing

Please see out contributing guidelines to help us improve this library!

Look and feel

Some corner cases:

// SET key value EX 10 NX
set, err := rdb.SetNX(ctx, "key", "value", 10*time.Second).Result()

// SET key value keepttl NX
set, err := rdb.SetNX(ctx, "key", "value", redis.KeepTTL).Result()

// SORT list LIMIT 0 2 ASC
vals, err := rdb.Sort(ctx, "list", &redis.Sort{Offset: 0, Count: 2, Order: "ASC"}).Result()

// ZRANGEBYSCORE zset -inf +inf WITHSCORES LIMIT 0 2
vals, err := rdb.ZRangeByScoreWithScores(ctx, "zset", &redis.ZRangeBy{
    Min: "-inf",
    Max: "+inf",
    Offset: 0,
    Count: 2,
}).Result()

// ZINTERSTORE out 2 zset1 zset2 WEIGHTS 2 3 AGGREGATE SUM
vals, err := rdb.ZInterStore(ctx, "out", &redis.ZStore{
    Keys: []string{"zset1", "zset2"},
    Weights: []int64{2, 3}
}).Result()

// EVAL "return {KEYS[1],ARGV[1]}" 1 "key" "hello"
vals, err := rdb.Eval(ctx, "return {KEYS[1],ARGV[1]}", []string{"key"}, "hello").Result()

// custom command
res, err := rdb.Do(ctx, "set", "key", "value").Result()

Run the test

go-redis will start a redis-server and run the test cases.

The paths of redis-server bin file and redis config file are defined in main_test.go:

var (
	redisServerBin, _  = filepath.Abs(filepath.Join("testdata", "redis", "src", "redis-server"))
	redisServerConf, _ = filepath.Abs(filepath.Join("testdata", "redis", "redis.conf"))
)

For local testing, you can change the variables to refer to your local files, or create a soft link to the corresponding folder for redis-server and copy the config file to testdata/redis/:

ln -s /usr/bin/redis-server ./go-redis/testdata/redis/src
cp ./go-redis/testdata/redis.conf ./go-redis/testdata/redis/

Lastly, run:

go test

Another option is to run your specific tests with an already running redis. The example below, tests against a redis running on port 9999.:

REDIS_PORT=9999 go test <your options>

See also

Contributors

Thanks to all the people who already contributed!