Cache describes a cache of files.
| 4 | |
| 5 | // Cache describes a cache of files. |
| 6 | type Cache interface { |
| 7 | // Size gets the size of the file. |
| 8 | Size(path string) (int64, bool) |
| 9 | |
| 10 | // PutSize sets size of the file. |
| 11 | PutSize(path string, length int64) bool |
| 12 | |
| 13 | // Exists checks if the given chunk of the file is already cached. |
| 14 | Exists(name string, offset int64) bool |
| 15 | |
| 16 | // GetOrCreate gets the cached value if available, otherwise downloads the file. |
| 17 | GetOrCreate(name string, offset int64, count int, fetch func() ([]byte, error)) ([]byte, error) |
| 18 | } |
| 19 | |
| 20 | var ( |
| 21 | // FilesCacheMaxCost is the capacity of the files cache. |
no outgoing calls
no test coverage detected