Documentation ¶
Index ¶
- type CachedFile
- type FileCache
- func (fc *FileCache) Get(path string) (*CachedFile, bool)
- func (fc *FileCache) Iterate(iterFunc func(*CachedFile))
- func (fc *FileCache) IterateOrdered(iterFunc func(*CachedFile))
- func (fc *FileCache) Put(f *CachedFile)
- func (fc *FileCache) Remove(path string)
- func (fc *FileCache) StartMonitor(d time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CachedFile ¶
type CachedFile struct { upmutex.UpgradeableMutex // contains filtered or unexported fields }
CachedFile provides a structure for managing a cached file including freshness, last refresh time etc
func NewFile ¶
func NewFile(path string, onDisk bool, content interface{}) *CachedFile
NewFile returns a new File based on supplied FileContents
func (*CachedFile) Content ¶
func (f *CachedFile) Content() interface{}
Content returns the underlying provided interface
func (*CachedFile) IsFresh ¶
func (f *CachedFile) IsFresh() bool
IsFresh returns whether the provided file is fresh
func (*CachedFile) UpdateLastRefresh ¶
func (f *CachedFile) UpdateLastRefresh()
UpdateLastRefresh updates the last refresh time to now and sets file as fresh
type FileCache ¶
type FileCache struct { upmutex.UpgradeableMutex // contains filtered or unexported fields }
FileCache is an LRU cache with filesystem monitoring. UpgradeableMutex is built-in to the FileCache and CachedFile objects it manages for multi-threading
func NewFileCache ¶
NewFileCache returns a new FileCache object of size, and max file age
func (*FileCache) Get ¶
func (fc *FileCache) Get(path string) (*CachedFile, bool)
Get looks for and tries to return a CachedFile object from the FileCache. NOTE: THIS IS NOT THREADSAFE, PLEASE USE FileCache.RLock()
func (*FileCache) Iterate ¶
func (fc *FileCache) Iterate(iterFunc func(*CachedFile))
Iterate performs an unordered iteration through the FileCache, performing provided function on each key,value pair. NOTE: THIS IS NOT THREAD SAFE, PLEASE USE FileCache.RLock()
func (*FileCache) IterateOrdered ¶
func (fc *FileCache) IterateOrdered(iterFunc func(*CachedFile))
IterateOrdered performs an ordered iteration through the FileCache, performing provided function on each key,value pair. NOTE: THIS IS NOT THREADSAFE OR WRITE SAFE, PLEASE DO NOT MODIFY THE FileCache MID-ITERATION, AND ENSURE TO USE FileCache.RLock()
func (*FileCache) Put ¶
func (fc *FileCache) Put(f *CachedFile)
Put places a CachedFile object in the FileCache. NOTE: THIS IS NOT THREADSAFE, PLEASE USE FileCache.Lock()
func (*FileCache) Remove ¶
Remove tries to remove a CachedFile with Path from the FileCache. NOTE: THIS IS NOT THREADSAFE, PLEASE USE FileCache.Lock()
func (*FileCache) StartMonitor ¶
StartMonitor starts the FileCache freshness monitor in its own goroutine