linstrom/storage/cache/lockedCoders.go
mStar 8709238859 Added goals, cache and func to get any remote obj
Cache is for storage, also includes pooled encoders and decoders
goals are things to eventually add to Linstrom
2024-09-06 23:01:57 +02:00

35 lines
489 B
Go

package cache
import (
"bytes"
"encoding/gob"
"sync"
)
type gobEncoder struct {
sync.Mutex
Encoder *gob.Encoder
Buffer *bytes.Buffer
}
func newEncoder() gobEncoder {
buf := bytes.Buffer{}
return gobEncoder{
Encoder: gob.NewEncoder(&buf),
Buffer: &buf,
}
}
type gobDecoder struct {
sync.Mutex
Decoder *gob.Decoder
Buffer *bytes.Buffer
}
func newDecoder() gobDecoder {
buf := bytes.Buffer{}
return gobDecoder{
Decoder: gob.NewDecoder(&buf),
Buffer: &buf,
}
}