Documentation ¶
Index ¶
- func ByteCountIEC(b int) string
- type ByTimestamp
- type Cache
- func (c *Cache) Close()
- func (c *Cache) DeleteFile(file string) error
- func (c *Cache) Get(key string) (reader *os.File, size int64, mtime time.Time, err error)
- func (c *Cache) Set(key string, mtime time.Time, resp []byte) error
- func (c *Cache) ShrinkDatabase() error
- func (c *Cache) StartBackgroundThread()
- func (c *Cache) UpdateCacheLimit(cacheLimit int)
- func (c *Cache) UpdateCacheRefreshAge(cacheRefreshAge int)
- func (c *Cache) UpdateCacheScanInterval(cacheScanInterval int)
- type KeyPair
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteCountIEC ¶
ByteCountIEC returns a human-readable string describing the size of bytes in int
Types ¶
type ByTimestamp ¶
type ByTimestamp []KeyPair
ByTimestamp is a sortable slice of KeyPair based off timestamp
func (ByTimestamp) Len ¶
func (a ByTimestamp) Len() int
func (ByTimestamp) Less ¶
func (a ByTimestamp) Less(i, j int) bool
func (ByTimestamp) Swap ¶
func (a ByTimestamp) Swap(i, j int)
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a struct that represents a cache object
func New ¶
func New(directory string, cacheLimit int, cacheScanInterval int, cacheRefreshAge int, maxCacheScanTime int, logger *logrus.Logger, clientCacheSizeCounter *metrics.Counter, clientCacheLimitCounter *metrics.Counter) *Cache
New returns a new Cache that will store files in basePath
func (*Cache) DeleteFile ¶
DeleteFile takes an absolute path to a file and deletes it
func (*Cache) Set ¶
Set takes a key, hashes it, and saves the `resp` bytearray into the corresponding file
func (*Cache) ShrinkDatabase ¶
ShrinkDatabase manually re-creates the cache.db file and effectively shrinks it
func (*Cache) StartBackgroundThread ¶
func (c *Cache) StartBackgroundThread()
StartBackgroundThread starts a background thread that automatically scans the directory and removes older files when cache exceeds size limits
func (*Cache) UpdateCacheLimit ¶
UpdateCacheLimit allows for updating of cache limit=
func (*Cache) UpdateCacheRefreshAge ¶
UpdateCacheRefreshAge allows for updating of cache refresh age
func (*Cache) UpdateCacheScanInterval ¶
UpdateCacheScanInterval allows for updating of cache scanning interval