We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1b11028 commit 93dd117Copy full SHA for 93dd117
internal/cache/cache.go
@@ -34,7 +34,10 @@ type CacheWrap struct {
34
}
35
36
func NewFileCache(path string) *FileCache {
37
- return &FileCache{path: path}
+ return &FileCache{
38
+ path: path,
39
+ wrap: &CacheWrap{RefreshedAt: time.Unix(0, 0)},
40
+ }
41
42
43
func (c *FileCache) Read(out any) error {
@@ -48,7 +51,7 @@ func (c *FileCache) Read(out any) error {
48
51
return err
49
52
50
53
- c.wrap = &CacheWrap{Data: out}
54
+ c.wrap.Data = out
55
56
err = json.Unmarshal(content, c.wrap)
57
if err == nil {
@@ -68,10 +71,6 @@ func (c *FileCache) Refresh(t time.Time) {
68
71
69
72
70
73
func (c *FileCache) RefreshedAt() time.Time {
- if c.wrap == nil {
- return time.Unix(0, 0)
- }
74
-
75
return c.wrap.RefreshedAt
76
77
0 commit comments