Skip to content

Commit be31d07

Browse files
committed
chore: switch to github.com/bytedance/sonic for JSON unmarshalling
- Add `github.com/bytedance/sonic` v1.12.7 to go.mod - Remove indirect dependency on `github.com/bytedance/sonic` from go.mod - Replace `encoding/json` with `github.com/bytedance/sonic` for JSON unmarshalling in redis.go Signed-off-by: appleboy <[email protected]>
1 parent 864d5d7 commit be31d07

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/golang-queue/redisdb
33
go 1.22
44

55
require (
6+
github.com/bytedance/sonic v1.12.7
67
github.com/golang-queue/queue v0.2.2-0.20250119150904-f91fef259091
78
github.com/redis/go-redis/v9 v9.7.0
89
github.com/stretchr/testify v1.10.0
@@ -15,7 +16,6 @@ require (
1516
dario.cat/mergo v1.0.0 // indirect
1617
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
1718
github.com/Microsoft/go-winio v0.6.2 // indirect
18-
github.com/bytedance/sonic v1.12.7 // indirect
1919
github.com/bytedance/sonic/loader v0.2.2 // indirect
2020
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
2121
github.com/cespare/xxhash/v2 v2.2.0 // indirect

redis.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package redisdb
22

33
import (
44
"context"
5-
"encoding/json"
65
"strings"
76
"sync"
87
"sync/atomic"
@@ -12,6 +11,7 @@ import (
1211
"github.com/golang-queue/queue/core"
1312
"github.com/golang-queue/queue/job"
1413

14+
"github.com/bytedance/sonic"
1515
"github.com/redis/go-redis/v9"
1616
"github.com/yassinebenaid/godump"
1717
)
@@ -163,7 +163,7 @@ loop:
163163
return nil, queue.ErrQueueHasBeenClosed
164164
}
165165
var data job.Message
166-
_ = json.Unmarshal([]byte(task.Payload), &data)
166+
_ = sonic.Unmarshal([]byte(task.Payload), &data)
167167
return &data, nil
168168
case <-time.After(1 * time.Second):
169169
if clock == 5 {

0 commit comments

Comments
 (0)