github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/cmd/camput/cache.go (about)

     1  /*
     2  Copyright 2012 Google Inc.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8       http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package main
    18  
    19  import (
    20  	"os"
    21  
    22  	"camlistore.org/pkg/blob"
    23  	"camlistore.org/pkg/client"
    24  )
    25  
    26  // A HaveCache tracks whether a remove blobserver has a blob or not.
    27  type HaveCache interface {
    28  	StatBlobCache(br blob.Ref) (size int64, ok bool)
    29  	NoteBlobExists(br blob.Ref, size int64)
    30  	Close() error
    31  }
    32  
    33  // UploadCache is the "stat cache" for regular files.  Given a current
    34  // working directory, possibly relative filename, stat info, and
    35  // whether that file was uploaded with a permanode (-filenodes),
    36  // returns what the ultimate put result (the top-level "file" schema
    37  // blob) for that regular file was.
    38  type UploadCache interface {
    39  	// CachedPutResult looks in the cache for the put result for the file
    40  	// that was uploaded. If withPermanode, it is only a hit if a planned
    41  	// permanode for the file was created and uploaded too, and vice-versa.
    42  	// The returned PutResult is always for the "file" schema blob.
    43  	CachedPutResult(pwd, filename string, fi os.FileInfo, withPermanode bool) (*client.PutResult, error)
    44  	// AddCachedPutResult stores in the cache the put result for the file that
    45  	// was uploaded. If withPermanode, it means a planned permanode was created
    46  	// for this file when it was uploaded (with -filenodes), and the cache entry
    47  	// will reflect that.
    48  	AddCachedPutResult(pwd, filename string, fi os.FileInfo, pr *client.PutResult, withPermanode bool)
    49  	Close() error
    50  }