Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer gob编码序列化器 使用Go标准库的encoding/gob包 优点:类型安全,支持复杂结构体,支持nil值 缺点:仅限Go语言使用,不能跨语言
func (*GobSerializer) Decode ¶
func (g *GobSerializer) Decode(data []byte, obj any) error
Decode 使用gob反序列化
func (*GobSerializer) Encode ¶
func (g *GobSerializer) Encode(value interface{}) ([]byte, error)
Encode 使用gob序列化缓存值
type JsonSerializer ¶
type JsonSerializer struct{}
JsonSerializer JSON序列化器 使用Go标准库的encoding/json包 优点:人类可读,跨语言支持,易于调试 缺点:性能较gob慢,某些类型支持不完整(如复杂指针、interface{})
func (*JsonSerializer) Decode ¶
func (j *JsonSerializer) Decode(data []byte, obj any) error
Decode 使用JSON反序列化
func (*JsonSerializer) Encode ¶
func (j *JsonSerializer) Encode(value interface{}) ([]byte, error)
Encode 使用JSON序列化缓存值
Click to show internal directories.
Click to hide internal directories.