github.com/fawick/restic@v0.1.1-0.20171126184616-c02923fbfc79/internal/restic/cache.go (about)

     1  package restic
     2  
     3  import "io"
     4  
     5  // Cache manages a local cache.
     6  type Cache interface {
     7  	// BaseDir returns the base directory of the cache.
     8  	BaseDir() string
     9  
    10  	// Wrap returns a backend with a cache.
    11  	Wrap(Backend) Backend
    12  
    13  	// IsNotExist returns true if the error was caused by a non-existing file.
    14  	IsNotExist(err error) bool
    15  
    16  	// Load returns a reader that yields the contents of the file with the
    17  	// given id if it is cached. rd must be closed after use. If an error is
    18  	// returned, the ReadCloser is nil. The files are still encrypted
    19  	Load(h Handle, length int, offset int64) (io.ReadCloser, error)
    20  
    21  	// SaveIndex saves an index in the cache.
    22  	Save(Handle, io.Reader) error
    23  
    24  	// SaveWriter returns a writer for the to be cached object h. It must be
    25  	// closed after writing is finished.
    26  	SaveWriter(Handle) (io.WriteCloser, error)
    27  
    28  	// Remove deletes a single file from the cache. If it isn't cached, this
    29  	// functions must return no error.
    30  	Remove(Handle) error
    31  
    32  	// Clear removes all files of type t from the cache that are not contained in the set.
    33  	Clear(FileType, IDSet) error
    34  
    35  	// Has returns true if the file is cached.
    36  	Has(Handle) bool
    37  }