1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-18 00:20:57 +03:00

268 Commits

Author SHA1 Message Date
4ac591c7c4 Set correct cluster slot for scan commands, similarly to Java's Jedis client (#2623)
- At present, the `scan` command is dispatched to a random slot.
- As far as I can tell, the scanX family of commands are not cluster aware (e.g. don't redirect the client to the correct slot).
- You can see [here](869dc0bb66/src/main/java/redis/clients/jedis/ShardedCommandObjects.java (L101)), the Jedis client calling `processKey` on the match argument, and this is what this PR also does.

We've had this patch running in production, and it seems to work well for us.

For further thought:
- Continuing looking at other Redis clients (e.g. Jedis), they outright [reject as invalid](869dc0bb66/src/main/java/redis/clients/jedis/ShardedCommandObjects.java (L98)) any scan command that does not include a hash-tag. Presumably this has the advantage of users not being surprised when their scan produces no results when a random server is picked.
- Perhaps it would be sensible for go-redis to do the same also?

Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-06-24 13:43:03 +03:00
7d97cc1c59 feat: optimize connection pool waitTurn (#3412) 2025-06-20 12:07:14 +03:00
eb40ac8328 perf: reduce unnecessary memory allocation (#3399)
Signed-off-by: fukua95 <fukua95@gmail.com>
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-06-09 11:59:58 +03:00
86d418f940 feat: Introducing StreamingCredentialsProvider for token based authentication (#3320)
* wip

* update documentation

* add streamingcredentialsprovider in options

* fix: put back option in pool creation

* add package level comment

* Initial re authentication implementation

Introduces the StreamingCredentialsProvider as the CredentialsProvider
with the highest priority.

TODO: needs to be tested

* Change function type name

Change CancelProviderFunc to UnsubscribeFunc

* add tests

* fix race in tests

* fix example tests

* wip, hooks refactor

* fix build

* update README.md

* update wordlist

* update README.md

* refactor(auth): early returns in cred listener

* fix(doctest): simulate some delay

* feat(conn): add close hook on conn

* fix(tests): simulate start/stop in mock credentials provider

* fix(auth): don't double close the conn

* docs(README): mark streaming credentials provider as experimental

* fix(auth): streamline auth err proccess

* fix(auth): check err on close conn

* chore(entraid): use the repo under redis org
2025-05-27 16:25:20 +03:00
c149644da7 Unit test for pool acquisition timeout (#3381)
Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
2025-05-19 19:46:19 +03:00
3af2cc5783 chore: optimize function ReplaceSpaces (#3383)
* chore: optimize function `ReplaceSpaces`

Signed-off-by: fukua95 <fukua95@gmail.com>

* trigger CI again because the bug of docker

Signed-off-by: fukua95 <fukua95@gmail.com>

* trigger CI again because the bug of docker

Signed-off-by: fukua95 <fukua95@gmail.com>

---------

Signed-off-by: fukua95 <fukua95@gmail.com>
2025-05-19 19:21:17 +03:00
43e7fb5eef test(util): add unit tests for Atoi, ParseInt, ParseUint, and ParseFloat (#3377) 2025-05-15 14:53:54 +03:00
42c32846e6 utils: export ParseFloat and MustParseFloat wrapping internal utils (#3371)
* utils: expose ParseFloat via new public utils package

* add tests for special float values in vector search
2025-05-09 12:24:36 +03:00
8ba559ca5d feat: add connection waiting statistics (#2804)
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2025-05-07 15:54:26 +03:00
9762559c75 Bound connection pool background dials to configured dial timeout (#3089) 2025-03-24 15:45:43 +02:00
ebe11d06ca feat: Enable CI for Redis CE 8.0 (#3274)
* chore: extract benchmark tests

* wip

* enable pubsub tests

* enable ring tests

* stop tests with build redis from source

* start all tests

* mix of makefile and action

* add sentinel configs

* fix example test

* stop debug on re

* wip

* enable gears for redis 7.2

* wip

* enable sentinel, they are expected to fail

* fix: linter configuration

* chore: update re versions

* return older redis enterprise version

* add basic codeql

* wip: increase timeout, focus only sentinel tests

* sentinels with docker network host

* enable all tests

* fix flanky test

* enable example tests

* tidy docker compose

* add debug output

* stop shutingdown masters

* don't test sentinel for re

* skip unsuported addscores

* Update README

bump go version in CI

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update CONTRIBUTING.md

add information about new test setup

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-02-28 12:49:00 +02:00
37accb4b28 fix: nil pointer dereferencing in writeArg (#3271)
* fixed bug with nil dereferencing in writeArg, added hset struct example, added tests

* removed password from example

* added omitempty

* reverted xxhash versioning

* reverted xxhash versioning

* removed password

* removed password

---------

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
2025-02-20 16:54:11 +02:00
e7868623ac Remove direct read from TLS underlying conn (#3138) 2024-10-07 12:23:11 +03:00
0858ed24e6 add test for tls connCheck #3025 (#3047)
* add a check for TLS connections.
2024-07-12 11:16:21 +08:00
244a3e22da RediSearch Support (#2801)
* Add RediSearch Support

* searach

* Add RediSearch commands and tests

* Adding more tests and fixing commands

* Remove unnecessary additions

* fixing tests

* fixing tests

* fixing tests

* fixing FTConfig dialect test

* fix commects

* make enum for field types

* Support resp 2

* fix golang ci

* fix ftinfo

---------

Co-authored-by: Chayim <chayim@users.noreply.github.com>
2024-06-26 13:13:06 +03:00
b64d9deef3 Handle IPv6 in isMovedError (#2981)
* Handle IPv6 in isMovedError

* Simplify GetAddr

---------

Co-authored-by: Monkey <golang@88.com>
2024-04-28 12:37:44 +08:00
5da49b1aba bug: Fix SETINFO ensuring it is set-and-forget (#2915)
* Exexcute set-info without validation

* Fix tests

* Remove spaces from runtime.Version

* fix typo

* Send setinfo after auth

* Add pipline

* fix golangci

* revert fixing typo

* support sentinel
2024-02-20 17:34:35 +02:00
9133749cd3 test: add ut for util_test (#2840)
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2024-02-14 22:16:50 +02:00
36bab9c8dc fix ConnPool race in newConn (#2885)
Co-authored-by: Oleg Stotskiy <ostotsky@ordercapital.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2024-02-14 22:14:50 +02:00
c828764336 Allow scanning redis values into pointer fields (#2787)
* Allow scanning redis values into pointer fields

* Formatting

---------

Co-authored-by: Ilia Personal <iliapersonal@Ilyas-MBP.station>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-12-17 17:42:45 +02:00
631deaf25f test: fix WriteArg test (#2808) 2023-12-17 12:13:01 +02:00
15682e3227 feat: support write the types of pointer of simple data types (#2745) (#2753)
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-10-31 07:17:22 +02:00
4408f8cfb2 free turn when leave with error (#2658)
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-10-30 17:42:26 +02:00
e23ea028bd Added MaxActiveConns (#2646)
* Added the ability to set a connection growth limit when there are not enough connections in the pool using MaxActiveConns

* fix comment

* fix

* fix

---------

Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-09-20 14:55:23 +03:00
e8ad794e96 Format code and fix go vet (#2696)
* run go fix ./...

Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com>

* run make fmt

Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com>

* fix go vet ./... issues

* Update README.md

Reorder imports with the rules defined in the Makefile 

as if we run `make fmt`

* run gofumpt -w .

* update Makefile to use gofumpt instead gofmt

* increment makefile

* format test

* format tests

Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com>

---------

Signed-off-by: Tiago Peczenyj <tpeczenyj@weborama.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
2023-09-20 14:03:44 +03:00
c0ab7815ea chore: fix staticcheck (#2631) 2023-07-02 14:38:52 +03:00
46f245075e fix: reader float parser (#2513) 2023-04-04 21:50:07 +08:00
6ec458549e Pointer -> Ptr (#2458) 2023-02-24 13:47:58 +08:00
3532f2a414 fix: limit the number of connections created (#2441)
* fix: limit the number of connections created

Signed-off-by: monkey92t <golang@88.com>
2023-02-14 18:01:53 +08:00
08b4cc5f4b feat: remove pool unused fields (#2438)
Signed-off-by: monkey92t <golang@88.com>
2023-02-12 18:50:25 +08:00
8db6eeed27 feat(scan): scan time.Time sets the default decoding (#2413)
* feat(scan): scan time.Time uses `UnmarshalText(RFC3339)` interface decoding by default
2023-02-07 20:23:39 +08:00
0023b80d82 chore: release v9.0.0 (release.sh) 2023-01-30 08:59:17 +02:00
7fa451c740 chore: fewer test dependencies 2023-01-27 15:01:50 +00:00
97b491aace chore: update import path 2023-01-23 08:48:54 +02:00
e314cd9846 Merge pull request #2356 from go-redis/fix/cursor-uint64
fix: read cursor as uint64
2023-01-20 15:15:43 +02:00
b88bd93662 fix: read cursor as uint64 2023-01-20 13:09:00 +02:00
d42dd1007c docs: add a description of the hook
Signed-off-by: monkey92t <golang@88.com>
2023-01-07 16:30:56 +08:00
a4336cbd43 feat(scan): add Scanner interface (#2317)
Signed-off-by: monkey92t <golang@88.com>
2022-12-24 22:29:45 +08:00
bbff4dd5dc chore: fix metrics in redisotel 2022-11-18 15:32:17 +02:00
e84461f7ed chore: release v9.0.0-rc.1 (release.sh) 2022-10-14 15:19:56 +03:00
58f7149e38 feat: add ContextTimeoutEnabled to respect context timeouts and deadlines 2022-10-11 10:22:42 +03:00
90625a3438 Merge pull request #2176 from j178/fix-read-timeout
fix(internal/pool): call SetDeadline even if timeout is zero
2022-10-05 10:41:42 +03:00
bac50ce2e9 chore: allow to disable timeouts 2022-10-05 10:36:12 +03:00
faa496ba7d test: vet that all Cmders have a SetVal() method 2022-08-07 22:40:51 -07:00
2123e08437 fix(internal/pool): call SetDeadline even if timeout is zero 2022-08-04 11:22:11 +08:00
b50b1c8f7a chore(internal): remove duplicate safe & unsafe 2022-08-02 00:11:40 +08:00
f6a8adc50c fix: remove conn reaper from the pool and uptrace option names 2022-07-28 15:17:59 +03:00
a18fad5bd3 chore: v9 2022-06-04 17:42:06 +03:00
d09c27e604 feat: upgrade to Redis 7 2022-06-04 17:25:12 +03:00
b0bb514059 fix: update COMMAND parser for Redis 7 2022-06-04 16:07:28 +03:00