Documentation ¶
Overview ¶
NKG: This is based on the LRU implementation by Google. I've made a few minor modifications, but it is otherwise intact.
Index ¶
- Variables
- func HandleIndex(res http.ResponseWriter, req *http.Request, fileCache FileCache)
- func NewFileCacheMiddleware(fileCache FileCache) martini.Handler
- func NewFileCacheWithConfig(config DiskFileCacheConfig) martini.Handler
- type CachedFile
- type DedupingDownloader
- type DiskFileCache
- type DiskFileCacheConfig
- type DownloadError
- type DownloadListener
- type DownloadListeners
- type DownloadPool
- type FileCache
- type Item
- type LRUCache
- type QueryCachedFiles
- type RemoteFileFetcher
- type UidManager
- type Value
- type WarmAndQueryCachedFiles
- type WarmCachedFiles
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultDiskFileCacheConfig = DiskFileCacheConfig{ // contains filtered or unexported fields }
Functions ¶
func HandleIndex ¶
func HandleIndex(res http.ResponseWriter, req *http.Request, fileCache FileCache)
func NewFileCacheMiddleware ¶
func NewFileCacheWithConfig ¶
func NewFileCacheWithConfig(config DiskFileCacheConfig) martini.Handler
Types ¶
type CachedFile ¶
func (*CachedFile) Delete ¶
func (cf *CachedFile) Delete()
func (*CachedFile) Size ¶
func (cf *CachedFile) Size() int
func (*CachedFile) StoreAsset ¶
func (cf *CachedFile) StoreAsset(body []byte)
func (*CachedFile) StoreMetadata ¶
func (cf *CachedFile) StoreMetadata()
type DedupingDownloader ¶
type DedupingDownloader struct {
// contains filtered or unexported fields
}
type DiskFileCache ¶
type DiskFileCache struct {
// contains filtered or unexported fields
}
func NewDiskFileCache ¶
func NewDiskFileCache(config DiskFileCacheConfig) *DiskFileCache
func (*DiskFileCache) Close ¶
func (dfc *DiskFileCache) Close()
func (*DiskFileCache) Query ¶
func (dfc *DiskFileCache) Query(tokens []string) *CachedFile
func (*DiskFileCache) Warm ¶
func (dfc *DiskFileCache) Warm(url string, fileAliases []string)
func (*DiskFileCache) WarmAndQuery ¶
func (dfc *DiskFileCache) WarmAndQuery(url string, fileAliases []string) *CachedFile
type DiskFileCacheConfig ¶
type DiskFileCacheConfig struct {
// contains filtered or unexported fields
}
type DownloadError ¶
type DownloadError struct {
// contains filtered or unexported fields
}
func (DownloadError) Error ¶
func (err DownloadError) Error() string
type DownloadListener ¶
type DownloadListener struct {
// contains filtered or unexported fields
}
type DownloadListeners ¶
type DownloadListeners struct {
// contains filtered or unexported fields
}
func NewDownloadListeners ¶
func NewDownloadListeners() *DownloadListeners
func (*DownloadListeners) Add ¶
func (downloadListeners *DownloadListeners) Add(url string, aliases []string, channel chan *CachedFile)
func (*DownloadListeners) Notify ¶
func (downloadListeners *DownloadListeners) Notify(cachedFile *CachedFile)
type DownloadPool ¶
type DownloadPool struct {
// contains filtered or unexported fields
}
func NewDownloadPool ¶
func NewDownloadPool() *DownloadPool
func (*DownloadPool) Download ¶
func (d *DownloadPool) Download(url string)
func (*DownloadPool) Finished ¶
func (d *DownloadPool) Finished(url string)
func (*DownloadPool) IsInTransit ¶
func (d *DownloadPool) IsInTransit(url string) (result bool)
type FileCache ¶
type FileCache interface { WarmAndQuery(url string, fileAliases []string) *CachedFile Query(tokens []string) *CachedFile Warm(url string, fileAliases []string) }
type LRUCache ¶
type LRUCache struct {
// contains filtered or unexported fields
}
func NewLRUCache ¶
func (*LRUCache) AddListener ¶
type QueryCachedFiles ¶
type QueryCachedFiles struct { Query []string Response chan *CachedFile }
type RemoteFileFetcher ¶
func DedupeWrapDownloader ¶
func DedupeWrapDownloader(downloader RemoteFileFetcher) RemoteFileFetcher
type UidManager ¶
type UidManager struct {
// contains filtered or unexported fields
}
func NewUidManager ¶
func NewUidManager() *UidManager
func (*UidManager) Generate ¶
func (um *UidManager) Generate() []byte
func (*UidManager) GenerateHex ¶
func (um *UidManager) GenerateHex() string
type Value ¶
type Value interface {
Size() int
}
Values that go into LRUCache need to satisfy this interface.
type WarmAndQueryCachedFiles ¶
type WarmAndQueryCachedFiles struct { Url string Aliases []string Response chan *CachedFile }
type WarmCachedFiles ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.