Documentation ¶
Index ¶
- Constants
- type DiskCache
- func (c *DiskCache) Add(key string, val *cacheobj.CacheObj) bool
- func (c *DiskCache) Capacity() uint64
- func (c *DiskCache) Close()
- func (c *DiskCache) Get(key string) (*cacheobj.CacheObj, bool)
- func (c *DiskCache) Keys() []string
- func (c *DiskCache) Peek(key string) (*cacheobj.CacheObj, bool)
- func (c *DiskCache) ResetAfterRestart()
- func (c *DiskCache) Size() uint64
- type MultiDiskCache
- func (c *MultiDiskCache) Add(key string, val *cacheobj.CacheObj) bool
- func (c *MultiDiskCache) Capacity() uint64
- func (c *MultiDiskCache) Close()
- func (c *MultiDiskCache) Get(key string) (*cacheobj.CacheObj, bool)
- func (c *MultiDiskCache) Keys() []string
- func (c *MultiDiskCache) Peek(key string) (*cacheobj.CacheObj, bool)
- func (c *MultiDiskCache) Size() uint64
Constants ¶
const BucketName = "b"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiskCache ¶
type DiskCache struct {
// contains filtered or unexported fields
}
func (*DiskCache) Add ¶
Add takes a key and value to add. Returns whether an eviction occurred The size is taken to fulfill the Cache interface, but the DiskCache doesn't use it. Instead, we compute size from the serialized bytes stored to disk.
Note DiskCache.Add does garbage collection in a goroutine, and thus it is not possible to determine eviction without impacting performance. This always returns false.
func (*DiskCache) Get ¶
Get takes a key, and returns its value, and whether it was found, and updates the lru-ness and hitcount
func (*DiskCache) Peek ¶
Peek takes a key, and returns its value, and whether it was found, without changing the lru-ness or hitcount
func (*DiskCache) ResetAfterRestart ¶
func (c *DiskCache) ResetAfterRestart()
ResetAfterRestart rebuilds the LRU with an arbirtrary order and sets sizeBytes. This seems crazy, but it is better than doing nothing, sice gc is based on the LRU and sizeBytes. In the future, we may want to periodically sync the LRU to disk, but we'll still need to iterate over all keys in the disk DB to avoid orphaning objects. Note: this assumes the LRU is empty. Don't run twice
type MultiDiskCache ¶
type MultiDiskCache []*DiskCache
MultiDiskCache is a disk cache using multiple files. It exists primarily to allow caching across multiple physical disks, but may be used for other purposes. For example, it may be more performant to use multiple files, or it may be advantageous to keep each remap rule in its own file. Keys are evenly distributed across the given files via consistent hashing.
func (*MultiDiskCache) Capacity ¶
func (c *MultiDiskCache) Capacity() uint64
func (*MultiDiskCache) Close ¶
func (c *MultiDiskCache) Close()
func (*MultiDiskCache) Keys ¶
func (c *MultiDiskCache) Keys() []string
func (*MultiDiskCache) Size ¶
func (c *MultiDiskCache) Size() uint64