Documentation ¶
Overview ¶
Package contentcache stores GCS object contents locally. Note: The content cache is not concurrent safe and callers should ensure thread safety
Index ¶
- Constants
- type CacheFileObjectMetadata
- type CacheObject
- type CacheObjectKey
- type ContentCache
- func (c *ContentCache) AddOrReplace(cacheObjectKey *CacheObjectKey, generation int64, metaGeneration int64, ...) (*CacheObject, error)
- func (c *ContentCache) Get(cacheObjectKey *CacheObjectKey) (*CacheObject, bool)
- func (c *ContentCache) NewCacheFile(rc io.ReadCloser, f *os.File) gcsx.TempFile
- func (c *ContentCache) NewTempFile(rc io.ReadCloser) (gcsx.TempFile, error)
- func (c *ContentCache) RecoverCache() error
- func (c *ContentCache) Remove(cacheObjectKey *CacheObjectKey)
- func (c *ContentCache) Size() int
- func (c *ContentCache) WriteMetadataCheckpointFile(cacheFileName string, cacheFileObjectMetadata *CacheFileObjectMetadata) (metadataFileName string, err error)
Constants ¶
const CacheFilePrefix = "gcsfusecache"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheFileObjectMetadata ¶
type CacheFileObjectMetadata struct { CacheFileNameOnDisk string BucketName string ObjectName string Generation int64 MetaGeneration int64 }
Metadata store struct
type CacheObject ¶
type CacheObject struct { MetadataFileName string CacheFileObjectMetadata *CacheFileObjectMetadata CacheFile gcsx.TempFile }
CacheObject is a wrapper struct for a cache file and its associated metadata
func (*CacheObject) Destroy ¶
func (c *CacheObject) Destroy()
Destroy performs disk clean up of cache files and metadata files
func (*CacheObject) ValidateGeneration ¶
func (c *CacheObject) ValidateGeneration(generation int64, metaGeneration int64) bool
ValidateGeneration compares fresh gcs object generation and metageneration numbers against cached objects
type CacheObjectKey ¶
CacheObjectKey uniquely identifies GCS objects by bucket name and object name
type ContentCache ¶
type ContentCache struct {
// contains filtered or unexported fields
}
ContentCache is a directory on local disk to store the object content ContentCache is thread-safe fileMap is an in memory map to represent cache contents on disk
func New ¶
func New(tempDir string, mtimeClock timeutil.Clock) *ContentCache
New creates a ContentCache.
func (*ContentCache) AddOrReplace ¶
func (c *ContentCache) AddOrReplace(cacheObjectKey *CacheObjectKey, generation int64, metaGeneration int64, rc io.ReadCloser) (*CacheObject, error)
AddOrReplace creates a new cache file or updates an existing cache file AddOrReplace is thread-safe
func (*ContentCache) Get ¶
func (c *ContentCache) Get(cacheObjectKey *CacheObjectKey) (*CacheObject, bool)
Get retrieves a file from the cache given the GCS object name and bucket name Get is thread-safe
func (*ContentCache) NewCacheFile ¶
func (c *ContentCache) NewCacheFile(rc io.ReadCloser, f *os.File) gcsx.TempFile
NewCacheFile returns a cache tempfile wrapper around the source reader and file
func (*ContentCache) NewTempFile ¶
func (c *ContentCache) NewTempFile(rc io.ReadCloser) (gcsx.TempFile, error)
NewTempFile returns a handle for a temporary file on the disk. The caller must call Destroy on the TempFile before releasing it.
func (*ContentCache) RecoverCache ¶
func (c *ContentCache) RecoverCache() error
RecoverCache recovers the cache with existing persisted files when gcsfuse starts RecoverCache should not be called concurrently
func (*ContentCache) Remove ¶
func (c *ContentCache) Remove(cacheObjectKey *CacheObjectKey)
Remove and destroys the specfied cache file and metadata on disk Remove is thread-safe
func (*ContentCache) Size ¶
func (c *ContentCache) Size() int
Size returns the size of the in memory map of cache files
func (*ContentCache) WriteMetadataCheckpointFile ¶
func (c *ContentCache) WriteMetadataCheckpointFile(cacheFileName string, cacheFileObjectMetadata *CacheFileObjectMetadata) (metadataFileName string, err error)
WriteMetadataCheckpointFile writes the metadata struct to a json file so cache files can be recovered on startup