Skip to content

Commit

Permalink
feat: set buff_send as default
Browse files Browse the repository at this point in the history
  • Loading branch information
suxb201 committed Dec 12, 2024
1 parent 7675749 commit 79a7536
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
8 changes: 0 additions & 8 deletions internal/client/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ func (r *Redis) Send(args ...interface{}) {
r.flush()
}

func (r *Redis) SendBytes(buf []byte) {
_, err := r.writer.Write(buf)
if err != nil {
log.Panicf(err.Error())
}
r.flush()
}

func (r *Redis) SendBytesBuff(buf []byte) {
r.mu.Lock()
defer r.mu.Unlock()
Expand Down
11 changes: 1 addition & 10 deletions internal/writer/redis_standalone_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type RedisWriterOptions struct {
Password string `mapstructure:"password" default:""`
Tls bool `mapstructure:"tls" default:"false"`
OffReply bool `mapstructure:"off_reply" default:"false"`
BuffSend bool `mapstructure:"buff_send" default:"false"`
Sentinel client.SentinelOptions `mapstructure:"sentinel"`
}

Expand All @@ -39,8 +38,6 @@ type redisStandaloneWriter struct {
ch chan *entry.Entry
chWg sync.WaitGroup

buffSend bool

stat struct {
Name string `json:"name"`
UnansweredBytes int64 `json:"unanswered_bytes"`
Expand All @@ -54,7 +51,6 @@ func NewRedisStandaloneWriter(ctx context.Context, opts *RedisWriterOptions) Wri
rw.stat.Name = "writer_" + strings.Replace(opts.Address, ":", "_", -1)
rw.client = client.NewRedisClient(ctx, opts.Address, opts.Username, opts.Password, opts.Tls, false)
rw.ch = make(chan *entry.Entry, 1024)
rw.buffSend = opts.BuffSend
if opts.OffReply {
log.Infof("turn off the reply of write")
rw.offReply = true
Expand Down Expand Up @@ -96,12 +92,7 @@ func (w *redisStandaloneWriter) StartWrite(ctx context.Context) chan *entry.Entr
atomic.AddInt64(&w.stat.UnansweredBytes, e.SerializedSize)
atomic.AddInt64(&w.stat.UnansweredEntries, 1)
}
if w.buffSend {
w.client.SendBytesBuff(bytes)
} else {
w.client.SendBytes(bytes)
}

w.client.SendBytesBuff(bytes)
}
w.chWg.Done()
}()
Expand Down
1 change: 0 additions & 1 deletion shake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ username = "" # keep empty if not using ACL
password = "" # keep empty if no authentication is required
tls = false
off_reply = false # turn off the server reply
buff_send = false # buffer send, default false. may be a sync delay when true, but it can greatly improve the speed

[filter]
# Allow keys with specific prefixes or suffixes
Expand Down

0 comments on commit 79a7536

Please sign in to comment.