mirror of
https://github.com/octoleo/restic.git
synced 2024-06-01 00:20:48 +00:00
9be24a1c9f
This commits adds rudimentary support for a cache directory, enabled by default. The cache directory is created if it does not exist. The cache is used if there's anything in it, newly created snapshot and index files are written to the cache automatically.
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package restic
|
|
|
|
import "io"
|
|
|
|
// Cache manages a local cache.
|
|
type Cache interface {
|
|
// Wrap returns a backend with a cache.
|
|
Wrap(Backend) Backend
|
|
|
|
// IsNotExist returns true if the error was caused by a non-existing file.
|
|
IsNotExist(err error) bool
|
|
|
|
// Load returns a reader that yields the contents of the file with the
|
|
// given id if it is cached. rd must be closed after use. If an error is
|
|
// returned, the ReadCloser is nil. The files are still encrypted
|
|
Load(h Handle, length int, offset int64) (io.ReadCloser, error)
|
|
|
|
// SaveIndex saves an index in the cache.
|
|
Save(Handle, io.Reader) error
|
|
|
|
// SaveWriter returns a writer for the to be cached object h. It must be
|
|
// closed after writing is finished.
|
|
SaveWriter(Handle) (io.WriteCloser, error)
|
|
|
|
// Remove deletes a single file from the cache. If it isn't cached, this
|
|
// functions must return no error.
|
|
Remove(Handle) error
|
|
|
|
// Clear removes all files of type t from the cache that are not contained in the set.
|
|
Clear(FileType, IDSet) error
|
|
|
|
// Has returns true if the file is cached.
|
|
Has(Handle) bool
|
|
}
|