(key string)
| 44 | } |
| 45 | |
| 46 | func (c FileCache) readValue(key string) (int64, string, error) { |
| 47 | path, err := c.cacheFilePath(key) |
| 48 | if err != nil { |
| 49 | return 0, "", err |
| 50 | } |
| 51 | data, err := os.ReadFile(path) |
| 52 | if err != nil { |
| 53 | return 0, "", err |
| 54 | } |
| 55 | split := strings.Split(string(data), separator) |
| 56 | if len(split) != 2 { |
| 57 | return 0, "", errors.New("Could not split cache data") |
| 58 | } |
| 59 | expiry, err := strconv.ParseInt(split[0], 10, 64) |
| 60 | if err != nil { |
| 61 | return 0, "", err |
| 62 | } |
| 63 | value := split[1] |
| 64 | return expiry, value, nil |
| 65 | } |
| 66 | |
| 67 | func (c FileCache) cacheFilePath(key string) (string, error) { |
| 68 | cacheDirectory, err := directories.Cache() |
no test coverage detected