mStar
8709238859
Cache is for storage, also includes pooled encoders and decoders goals are things to eventually add to Linstrom
35 lines
489 B
Go
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,
|
|
}
|
|
}
|