mirror of
https://github.com/redis/go-redis.git
synced 2026-10-24 07:59:20 +03:00
* feat(csc): metadata-driven command eligibility * fix linting issues * feat(csc): add dynamic metadata resolver * fix incompatibillity issues * fix issues * fix issues * fix issues * feat(csc): share dynamic command metadata * correct cluster metadata and routing * Reuse identicle records without building it from scratch again * Address comments * Address comments * Address comments * Address ci failures * harden metadata and cluster routing * verify metadata and list all nodes * fix hello callback * Perf improvements * fix bless scan routing methods * refactor(csc): separate cluster routing * Add server identification in HELLO && Split csc checks in autopipline
32 lines
963 B
Go
32 lines
963 B
Go
package redis
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
// TestCSCKeyGateAllocatesNothing pins that the key check processCached runs
|
|
// on every cached read, hits included, does not allocate.
|
|
func TestCSCKeyGateAllocatesNothing(t *testing.T) {
|
|
ctx := context.Background()
|
|
// A no-op cmdable builds the typed commands without any I/O.
|
|
c := cmdable(func(context.Context, Cmder) error { return nil })
|
|
cmds := map[string]Cmder{
|
|
"get": c.Get(ctx, "k"),
|
|
"mget": c.MGet(ctx, "a", "b", "c"),
|
|
"zinter": c.ZInter(ctx, &ZStore{Keys: []string{"a", "b"}}),
|
|
"lcs": c.LCS(ctx, &LCSQuery{Key1: "a", Key2: "b"}),
|
|
}
|
|
for name, cmd := range cmds {
|
|
meta, ok := cscCommandMetaFor(cmd)
|
|
if !ok || !cscCanExtractRedisKeys(meta, cmd) {
|
|
t.Fatalf("%s: keys not renderable", name)
|
|
}
|
|
if n := testing.AllocsPerRun(100, func() {
|
|
_ = cscCanExtractRedisKeys(meta, cmd)
|
|
}); n != 0 {
|
|
t.Errorf("%s: key gate allocates %v objects per call, want 0", name, n)
|
|
}
|
|
}
|
|
}
|