app

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2014 License: MIT Imports: 14 Imported by: 0

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

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 NewFileCacheMiddleware(fileCache FileCache) martini.Handler

func NewFileCacheWithConfig

func NewFileCacheWithConfig(config DiskFileCacheConfig) martini.Handler

Types

type CachedFile

type CachedFile struct {
	ContentHash string
	Url         string
	Aliases     []string
	Path        string
}

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 Item

type Item struct {
	Key   string
	Value Value
}

type LRUCache

type LRUCache struct {
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache(capacity uint64) *LRUCache

func (*LRUCache) AddListener

func (lru *LRUCache) AddListener(listener chan *Item)

func (*LRUCache) Get

func (lru *LRUCache) Get(key string) (v Value, ok bool)

func (*LRUCache) Set

func (lru *LRUCache) Set(key string, value Value)

type QueryCachedFiles

type QueryCachedFiles struct {
	Query    []string
	Response chan *CachedFile
}

type RemoteFileFetcher

type RemoteFileFetcher func(url string) ([]byte, error)

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

type WarmCachedFiles struct {
	Url     string
	Aliases []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL