Documentation
¶
Overview ¶
Package serializer defines the value encoding boundary used by cache. Built-in JSON and MessagePack implementations are available through New; callers can implement Serializer and inject it with cache.WithSerializer. Changing encodings requires invalidating existing entries or changing the cache key prefix because values written by one encoding may not decode with another.
Example ¶
package main
import (
"github.com/ceyewan/genesis/cache/serializer"
)
func main() {
codec, err := serializer.New("json")
if err != nil {
return
}
_, _ = codec.Marshal(map[string]string{"status": "ok"})
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnsupportedSerializer 不支持的序列化器类型。 ErrUnsupportedSerializer = xerrors.New("unsupported serializer type") )
错误定义
Functions ¶
This section is empty.
Types ¶
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer JSON 序列化器
type MessagePackSerializer ¶
type MessagePackSerializer struct{}
MessagePackSerializer MessagePack 序列化器
Click to show internal directories.
Click to hide internal directories.