aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/cache/cache.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 21:22:38 +0100
committerRené 'Necoro' Neumann <necoro@necoro.eu>2021-02-27 21:22:38 +0100
commitae96e1bd2516ff2c70ad9dc010da84b7a03b9a35 (patch)
tree319e04d268ca1c881205c89da45ad0c1f161bd23 /internal/feed/cache/cache.go
parentcf3e619639a9e1fd182e0c2437a0619e3ee2ab7f (diff)
downloadfeed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.tar.gz
feed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.tar.bz2
feed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.zip
Put storing / loading details into cache implementation
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)
}