diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-27 21:22:38 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2021-02-27 21:22:38 +0100 |
commit | ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35 (patch) | |
tree | 319e04d268ca1c881205c89da45ad0c1f161bd23 /internal/feed/cache/v1.go | |
parent | cf3e619639a9e1fd182e0c2437a0619e3ee2ab7f (diff) | |
download | feed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.tar.gz feed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.tar.bz2 feed2imap-go-ae96e1bd2516ff2c70ad9dc010da84b7a03b9a35.zip |
Put storing / loading details into cache implementation
Diffstat (limited to '')
-rw-r--r-- | internal/feed/cache/v1.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/feed/cache/v1.go b/internal/feed/cache/v1.go index 7d95d4c..17a0346 100644 --- a/internal/feed/cache/v1.go +++ b/internal/feed/cache/v1.go @@ -3,8 +3,10 @@ package cache import ( "crypto/sha256" "encoding/base64" + "encoding/gob" "encoding/hex" "fmt" + "io" "sort" "strconv" "strings" @@ -373,3 +375,13 @@ func filterItems(items []cachedItem) []cachedItem { return copiedItems } + +func (cache *v1Cache) load(reader io.Reader) error { + decoder := gob.NewDecoder(reader) + return decoder.Decode(cache) +} + +func (cache *v1Cache) store(writer io.Writer) error { + encoder := gob.NewEncoder(writer) + return encoder.Encode(cache) +} |