Skip to content

Commit

Permalink
Improve the readability of redis_client util method (#4262)
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala authored Nov 1, 2024
1 parent 8cb9728 commit e19ab71
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pkg/cache/redis_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,7 @@ func (c *RedisClient) Close() error {
return c.rdb.Close()
}

// StringToBytes converts string to byte slice. (copied from vendor/github.com/go-redis/redis/v8/internal/util/unsafe.go)
// StringToBytes reads the string header and returns a byte slice without copying.
func StringToBytes(s string) []byte {
return *(*[]byte)(unsafe.Pointer(
&struct {
string
Cap int
}{s, len(s)},
))
return unsafe.Slice(unsafe.StringData(s), len(s))
}

0 comments on commit e19ab71

Please sign in to comment.