-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redis prefix
- Loading branch information
Showing
5 changed files
with
117 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package rockscache | ||
|
||
import ( | ||
jsoniter "github.com/json-iterator/go" | ||
) | ||
|
||
type ( | ||
// Codec interface | ||
Codec interface { | ||
// Encode encodes the provided value into a byte slice. | ||
Encode(interface{}) ([]byte, error) | ||
|
||
// Decode decodes the provided byte slice into a value. | ||
Decode([]byte, interface{}) error | ||
} | ||
|
||
// default codec | ||
codec struct { | ||
} | ||
) | ||
|
||
var _ Codec = (*codec)(nil) | ||
|
||
// Encode encodes the given value into a JSON byte array. | ||
func (c *codec) Encode(v any) ([]byte, error) { | ||
return jsoniter.Marshal(v) | ||
} | ||
|
||
// Decode decodes binary data into a value pointed to by v using JSON encoding. | ||
func (c *codec) Decode(data []byte, v any) error { | ||
return jsoniter.Unmarshal(data, v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters