aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache/cache.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/feed/cache/cache.go')
-rw-r--r--internal/feed/cache/cache.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/feed/cache/cache.go b/internal/feed/cache/cache.go
index 3a80df1..9613f06 100644
--- a/internal/feed/cache/cache.go
+++ b/internal/feed/cache/cache.go
@@ -2,9 +2,9 @@ package cache
import (
"bufio"
- "encoding/gob"
"errors"
"fmt"
+ "io"
"os"
"path/filepath"
"time"
@@ -24,6 +24,8 @@ const (
type Impl interface {
cachedFeed(*feed.Feed) CachedFeed
transformTo(Version) (Impl, error)
+ load(io.Reader) error
+ store(io.Writer) error
Version() Version
Info() string
SpecificInfo(interface{}) string
@@ -103,8 +105,7 @@ func (cache *Cache) store(fileName string) error {
return fmt.Errorf("writing to '%s': %w", fileName, err)
}
- encoder := gob.NewEncoder(writer)
- if err = encoder.Encode(cache.Impl); err != nil {
+ if err = cache.Impl.store(writer); err != nil {
return fmt.Errorf("encoding cache: %w", err)
}
@@ -164,8 +165,7 @@ func Load(fileName string) (Cache, error) {
return Cache{}, err
}
- decoder := gob.NewDecoder(reader)
- if err = decoder.Decode(cache); err != nil {
+ if err = cache.load(reader); err != nil {
return Cache{}, fmt.Errorf("decoding for version '%d' from '%s': %w", version, fileName, err)
}
>Make gpg errors fatalJason A. Donenfeld1-5/+5 2016-02-06Moved to webpageJason A. Donenfeld1-7/+0