Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlobCacheOptions ¶
type BlobCacheOptions struct {
// Dir is the directory where cache files are stored.
Dir string
// MaxSize is the maximum bytes on disk (default 1GB).
MaxSize int64
// MaxItemSize is the maximum size for a single item.
// Items larger than this will not be cached.
// Default 0 means no limit.
MaxItemSize int64
}
BlobCacheOptions configures a BlobCache.
type Cache ¶
type Cache interface {
Get(key string) ([]byte, bool)
Set(key string, data []byte) error
Remove(key string)
Clear() error
Stats() Stats
Close() error
}
Cache is a generic diskcache interface.
func NewBlobCache ¶
func NewBlobCache(opts BlobCacheOptions) (Cache, error)
NewBlobCache creates a new blob cache with the given options.
type FileBackedCache ¶
type FileBackedCache interface {
RefCountedCache
CacheDir() string
// SetFromFile promotes a temp file into the cache under key.
// tempPath should point to a file on the same filesystem as CacheDir.
SetFromFile(key, tempPath string, size int64) error
}
type RefCountedCache ¶
type RefCountedCache interface {
Cache
// Acquire retrieves data and increments its reference count.
// The entry will not be evicted until Release is called.
// Returns the data and true if found, nil and false otherwise.
Acquire(key string) ([]byte, bool)
// Release decrements the reference count for an entry.
// When the count reaches zero, the entry becomes eligible for eviction.
Release(key string)
}
RefCountedCache extends Cache with reference counting. Reference counting prevents entries from being evicted while in use.
func NewSSTCache ¶
func NewSSTCache(opts SSTCacheOptions) (RefCountedCache, error)
NewSSTCache creates a new SST cache with the given options.
type SSTCacheOptions ¶
type SSTCacheOptions struct {
Dir string
// MaxSize is the maximum bytes on disk (default 1GB).
MaxSize int64
}
SSTCacheOptions configures an SSTCache.
Click to show internal directories.
Click to hide internal directories.