Documentation ¶
Index ¶
- Constants
- Variables
- func DetectMimetype(f *os.File) (mimetype string, err error)
- func GetMimetypeFromContent(r io.Reader, fileSize int64) (mimetype string, err error)
- type Lru
- func (lru *Lru) All() []LruKey
- func (lru *Lru) Count() int
- func (lru *Lru) Drop(id LruKey) (found bool, err error)
- func (lru *Lru) Dump()
- func (lru *Lru) Exists(id LruKey) bool
- func (lru *Lru) FindPosition(id LruKey) int
- func (lru *Lru) Get(id LruKey) (found bool, item LruItem, err error)
- func (lru *Lru) IsFull() bool
- func (lru *Lru) MaxCount() int
- func (lru *Lru) Newest() LruKey
- func (lru *Lru) Oldest() LruKey
- func (lru *Lru) PopOldest() (item LruItem, err error)
- func (lru *Lru) Set(item LruItem) (added bool, droppedItem LruItem, err error)
- func (lru *Lru) SetDropCb(cb lruEventFunc)
- type LruItem
- type LruKey
Constants ¶
View Source
const (
MimetypeLeadBytesCount = 512
)
Variables ¶
View Source
var ( // ErrLruEmpty indicates that the LRU is empty.. ErrLruEmpty = errors.New("lru is empty") )
Functions ¶
func DetectMimetype ¶
DetectMimetype is a wrapper for GetMimetypeFromContent which returns the mime-type for the given `File`. An empty-string is returned if it is a zero- length file.
Types ¶
type Lru ¶
type Lru struct {
// contains filtered or unexported fields
}
Lru establises an LRU of IDs of any type.
func (*Lru) FindPosition ¶
FindPosition will return the numerical position in the list. Since the LRU will never be very large, this call is not expensive, per se. But, it *is* O(n) and any call to us will compound with any loops you happen to wrap us into.
func (*Lru) PopOldest ¶
PopOldest will pop the oldest entry out of the LRU and return it. It will return ErrLruEmpty when empty.
Click to show internal directories.
Click to hide internal directories.