Skip to content

Commit

Permalink
Improve the readability of redis_client util method
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Nov 1, 2024
1 parent 44c18cc commit 014f252
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 014f252

Please sign in to comment.