Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func AutoCommit(cmd TxnCommand) Command {
}

func feedMonitors(ctx *Context) {
ctx.Server.Monitors.Range(func(k, v interface{}) bool {
ctx.Server.Monitors.Range(func(k, v any) bool {
mCtx := v.(*Context)
if mCtx.Client.Namespace != sysAdminNamespace && mCtx.Client.Namespace != ctx.Client.Namespace {
return true
Expand Down
6 changes: 3 additions & 3 deletions command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Client(ctx *Context) {
now := time.Now()
var lines []string
clients := &ctx.Server.Clients
clients.Range(func(k, v interface{}) bool {
clients.Range(func(k, v any) bool {
client := v.(*context.ClientContext)
if ctx.Client.Namespace != sysAdminNamespace && client.Namespace != ctx.Client.Namespace {
return true
Expand Down Expand Up @@ -145,7 +145,7 @@ func Client(ctx *Context) {
// now kill clients with above rules
killed := 0
closeSelf := false
ctx.Server.Clients.Range(func(k, v interface{}) bool {
ctx.Server.Clients.Range(func(k, v any) bool {
cli := v.(*context.ClientContext)

if cli.Namespace != sysAdminNamespace && cli.Namespace != ctx.Client.Namespace {
Expand Down Expand Up @@ -366,7 +366,7 @@ func Info(ctx *Context) {

// count the number of clients
var numberOfClients int
ctx.Server.Clients.Range(func(k, v interface{}) bool {
ctx.Server.Clients.Range(func(k, v any) bool {
numberOfClients++
return true
})
Expand Down
4 changes: 2 additions & 2 deletions command/sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ type MinHeap []*db.SetIter
func (h MinHeap) Len() int { return len(h) }
func (h MinHeap) Less(i, j int) bool { return bytes.Compare(h[i].Value(), h[j].Value()) < 0 }
func (h MinHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
func (h *MinHeap) Push(x interface{}) {
func (h *MinHeap) Push(x any) {
item := x.(*db.SetIter)
*h = append(*h, item)
}

func (h *MinHeap) Pop() interface{} {
func (h *MinHeap) Pop() any {
old := *h
n := len(old)
item := old[n-1]
Expand Down
2 changes: 1 addition & 1 deletion context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func WithTimeout(parent *Context, timeout time.Duration) (*Context, CancelFunc)
}

// WithValue returns a copy of parent in which the value associated with key is val.
func WithValue(parent *Context, key, val interface{}) *Context {
func WithValue(parent *Context, key, val any) *Context {
ctx := *parent
ctx.Context = context.WithValue(parent.Context, key, val)
return &ctx
Expand Down
6 changes: 3 additions & 3 deletions db/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
PriorityHigh
)

//type rename tidb kv type
// type rename tidb kv type
type (
// Storage defines the interface for storage.
Storage kv.Storage
Expand All @@ -54,7 +54,7 @@ type (
Option kv.Option
)

//Open create tikv db ,create fake db if addr contains mockaddr
// Open create tikv db ,create fake db if addr contains mockaddr
func Open(addrs string) (r Storage, e error) {
if strings.Contains(addrs, MockAddr) {
return MockOpen(addrs)
Expand Down Expand Up @@ -96,7 +96,7 @@ func BatchGetValues(txn Transaction, keys [][]byte) (map[string][]byte, error) {
return txn.BatchGet(kvkeys)
}

func SetOption(txn Transaction, opt Option, val interface{}) {
func SetOption(txn Transaction, opt Option, val any) {
txn.SetOption(kv.Option(opt), val)
}

Expand Down
100 changes: 50 additions & 50 deletions tools/autotest/cmd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import (
"github.com/stretchr/testify/assert"
)

//ExampleKey verify the key command
// ExampleKey verify the key command
type ExampleKey struct {
conn redis.Conn
}

//NewExampleKey create key object
// NewExampleKey create key object
func NewExampleKey(conn redis.Conn) *ExampleKey {
return &ExampleKey{
conn: conn,
}
}

//DelEqual verify that the return value of the del key operation is correct
// DelEqual verify that the return value of the del key operation is correct
func (ek *ExampleKey) DelEqual(t *testing.T, expectReply int, keys ...string) {
req := make([]interface{}, len(keys))
req := make([]any, len(keys))
for i, eky := range keys {
req[i] = eky
}
Expand All @@ -30,15 +30,15 @@ func (ek *ExampleKey) DelEqual(t *testing.T, expectReply int, keys ...string) {
assert.NoError(t, err)
}

//DelEqualErr verify that the return error value of the del key operation is correct
func (ek *ExampleKey) DelEqualErr(t *testing.T, errValue string, args ...interface{}) {
// DelEqualErr verify that the return error value of the del key operation is correct
func (ek *ExampleKey) DelEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("del", args...)
assert.EqualError(t, err, errValue)
}

//ExistsEqual verify that the return value of the exists key operation is correct
// ExistsEqual verify that the return value of the exists key operation is correct
func (ek *ExampleKey) ExistsEqual(t *testing.T, expectReply int, keys ...string) {
req := make([]interface{}, len(keys))
req := make([]any, len(keys))
for i, eky := range keys {
req[i] = eky
}
Expand All @@ -47,53 +47,53 @@ func (ek *ExampleKey) ExistsEqual(t *testing.T, expectReply int, keys ...string)
assert.NoError(t, err)
}

//ExistsEqualErr verify that the return error value of the exists key operation is correct
func (ek *ExampleKey) ExistsEqualErr(t *testing.T, errValue string, args ...interface{}) {
// ExistsEqualErr verify that the return error value of the exists key operation is correct
func (ek *ExampleKey) ExistsEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("exists", args...)
assert.EqualError(t, err, errValue)
}

//TTLEqual verify that the return value of the ttl key operation is correct
// TTLEqual verify that the return value of the ttl key operation is correct
func (ek *ExampleKey) TTLEqual(t *testing.T, key string, expectReply int) {
reply, err := redis.Int(ek.conn.Do("ttl", key))
assert.Equal(t, expectReply, reply)
assert.NoError(t, err)
}

//TTLEqualErr verify that the return error value of the ttl key operation is correct
func (ek *ExampleKey) TTLEqualErr(t *testing.T, errValue string, args ...interface{}) {
// TTLEqualErr verify that the return error value of the ttl key operation is correct
func (ek *ExampleKey) TTLEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("ttl", args...)
assert.EqualError(t, err, errValue)
}

//PTTLEqual verify that the return value of the ttl key operation is correct
// PTTLEqual verify that the return value of the ttl key operation is correct
func (ek *ExampleKey) PTTLEqual(t *testing.T, key string, expectReply int) {
reply, err := redis.Int(ek.conn.Do("ttl", key))
assert.Equal(t, expectReply, reply)
assert.NoError(t, err)
}

//PTTLEqualErr verify that the return error value of the ttl key operation is correct
func (ek *ExampleKey) PTTLEqualErr(t *testing.T, errValue string, args ...interface{}) {
// PTTLEqualErr verify that the return error value of the ttl key operation is correct
func (ek *ExampleKey) PTTLEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("ttl", args...)
assert.EqualError(t, err, errValue)
}

//Info TODO
func (ek *ExampleKey) Info(t *testing.T, key string, expectReply interface{}) {
// Info TODO
func (ek *ExampleKey) Info(t *testing.T, key string, expectReply any) {

}

//InfoEqualErr TODO
func (ek *ExampleKey) InfoEqualErr(t *testing.T, errValue string, args ...interface{}) {
// InfoEqualErr TODO
func (ek *ExampleKey) InfoEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("info", args...)
assert.EqualError(t, err, errValue)
}

//ScanEqual verify that the return value of the scan key operation is correct
//default scan all key in store
// ScanEqual verify that the return value of the scan key operation is correct
// default scan all key in store
func (ek *ExampleKey) ScanEqual(t *testing.T, match string, expectCount int) {
var reply interface{}
var reply any
var err error
if match == "" {
reply, err = ek.conn.Do("Scan", 0, "count", 10000)
Expand All @@ -106,115 +106,115 @@ func (ek *ExampleKey) ScanEqual(t *testing.T, match string, expectCount int) {
assert.NoError(t, err)
}

//ScanEqualErr verify that the return err value of the scan key operation is correct
func (ek *ExampleKey) ScanEqualErr(t *testing.T, errValue string, args ...interface{}) {
// ScanEqualErr verify that the return err value of the scan key operation is correct
func (ek *ExampleKey) ScanEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("scan", args...)
assert.EqualError(t, err, errValue)
}

//RandomKeyEqual verify that the return value of the random key operation is correct
// RandomKeyEqual verify that the return value of the random key operation is correct
func (ek *ExampleKey) RandomKeyEqual(t *testing.T) {
_, err := ek.conn.Do("RANDOMKEY")
assert.NoError(t, err)
}

//RandomKeyEqualErr verify that the return err value of the random key operation is correct
func (ek *ExampleKey) RandomKeyEqualErr(t *testing.T, errValue string, args ...interface{}) {
// RandomKeyEqualErr verify that the return err value of the random key operation is correct
func (ek *ExampleKey) RandomKeyEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("Randomkey", args...)
assert.EqualError(t, err, errValue)
}

//ExpireEqual verify that the return value of the expire key operation is correct
// ExpireEqual verify that the return value of the expire key operation is correct
func (ek *ExampleKey) ExpireEqual(t *testing.T, key string, value, expectValue int) {
reply, err := redis.Int(ek.conn.Do("expire", key, value))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

//ExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) ExpireEqualErr(t *testing.T, errValue string, args ...interface{}) {
// ExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) ExpireEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("expire", args...)
assert.EqualError(t, err, errValue)
}

//ExpireAtEqual verify that the return value of the expire key operation is correct
// ExpireAtEqual verify that the return value of the expire key operation is correct
func (ek *ExampleKey) ExpireAtEqual(t *testing.T, key string, value, expectValue int) {
reply, err := redis.Int(ek.conn.Do("expireat", key, value))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

//AtExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) ExpireAtEqualErr(t *testing.T, errValue string, args ...interface{}) {
// AtExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) ExpireAtEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("expireat", args...)
assert.EqualError(t, err, errValue)
}

//PExpireEqual verify that the return value of the expire key operation is correct
// PExpireEqual verify that the return value of the expire key operation is correct
func (ek *ExampleKey) PExpireEqual(t *testing.T, key string, value, expectValue int) {
reply, err := redis.Int(ek.conn.Do("pexpire", key, value))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

//PExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PExpireEqualErr(t *testing.T, errValue string, args ...interface{}) {
// PExpireEqualErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PExpireEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("pexpire", args...)
assert.EqualError(t, err, errValue)
}

//ExpireAtEqual verify that the return value of the expire key operation is correct
// ExpireAtEqual verify that the return value of the expire key operation is correct
func (ek *ExampleKey) PExpireAtEqual(t *testing.T, key string, value, expectValue int) {
reply, err := redis.Int(ek.conn.Do("pexpireat", key, value))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

//PExpireEqualAtErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PExpireAtEqualErr(t *testing.T, errValue string, args ...interface{}) {
// PExpireEqualAtErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PExpireAtEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("pexpireat", args...)
assert.EqualError(t, err, errValue)
}

func (ek *ExampleKey) TypeEqual(t *testing.T, key string, expectValue interface{}) {
func (ek *ExampleKey) TypeEqual(t *testing.T, key string, expectValue any) {
reply, err := redis.String(ek.conn.Do("type", key))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

func (ek *ExampleKey) TypeEqualErr(t *testing.T, errValue string, args ...interface{}) {
func (ek *ExampleKey) TypeEqualErr(t *testing.T, errValue string, args ...any) {
_, err := redis.String(ek.conn.Do("type", args...))
assert.EqualError(t, err, errValue)
}

func (ek *ExampleKey) KeysEqual(t *testing.T, key string, expectValue interface{}) {
func (ek *ExampleKey) KeysEqual(t *testing.T, key string, expectValue any) {
}

func (ek *ExampleKey) KeysEqualErr(t *testing.T, errValue string, expectValue interface{}) {
func (ek *ExampleKey) KeysEqualErr(t *testing.T, errValue string, expectValue any) {
}

func (ek *ExampleKey) ObjectEqual(t *testing.T, key string, expectValue interface{}) {
func (ek *ExampleKey) ObjectEqual(t *testing.T, key string, expectValue any) {
reply, err := redis.String(ek.conn.Do("object", "encoding", key))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

func (ek *ExampleKey) ObjectEqualErr(t *testing.T, errValue string, args ...interface{}) {
tmp := []interface{}{"encoding"}
func (ek *ExampleKey) ObjectEqualErr(t *testing.T, errValue string, args ...any) {
tmp := []any{"encoding"}
tmp = append(tmp, args...)
_, err := redis.String(ek.conn.Do("object", tmp...))
assert.EqualError(t, err, errValue)
}

//Persist verify that the return value of the expire key operation is correct
// Persist verify that the return value of the expire key operation is correct
func (ek *ExampleKey) PersistEqual(t *testing.T, key string, expectValue int) {
reply, err := redis.Int(ek.conn.Do("persist", key))
assert.NoError(t, err)
assert.Equal(t, expectValue, reply)
}

//PersistEqualAtErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PersistEqualErr(t *testing.T, errValue string, args ...interface{}) {
// PersistEqualAtErr verify that the err return value of the expire key operation is correct
func (ek *ExampleKey) PersistEqualErr(t *testing.T, errValue string, args ...any) {
_, err := ek.conn.Do("persist", args...)
assert.EqualError(t, err, errValue)
}
Loading