func (mc *MimeCache) Get(key string) string {
	if mti, ok := mc.mem.Get(key); ok {
		return mti.(string)
	}
	if mc.db != nil {
		if mimetype, err := mc.db.Get(key); err == nil {
			return mimetype
		}
	}
	return ""
}
Get returns the stored mimetype for the key - empty string if not found
package camutil
import (
	"bytes"
	"io"
	"github.com/h2non/filetype"
	"github.com/hashicorp/golang-lru"
	"perkeep.org/pkg/sorted"
	"perkeep.org/pkg/sorted/kvfile"
)
var DefaultMaxMemMimeCacheSize = 1024
func MIMETypeFromReader(r io.Reader) (mime string, reader io.Reader) {
	if r == nil {
		return "", nil
	}
	var buf bytes.Buffer
	_, err := io.Copy(&buf, io.LimitReader(r, 1024))
	mt, _ := filetype.Match(buf.Bytes())
	mime = mt.MIME.Type + "/" + mt.MIME.Subtype
	if err != nil {
		return mime, io.MultiReader(bytes.NewReader(buf.Bytes()), errReader{err})
	}
	return mime, io.MultiReader(bytes.NewReader(buf.Bytes()), r)
}
type MimeCache struct {
	mem *lru.TwoQueueCache
	db  sorted.KeyValue
}
func NewMimeCache(filename string, maxMemCacheSize int) *MimeCache {
	mc := new(MimeCache)
	if maxMemCacheSize <= 0 {
		maxMemCacheSize = DefaultMaxMemMimeCacheSize
	}
	var err error
	if mc.mem, err = lru.New2Q(maxMemCacheSize); err != nil {
		panic(err)
	}
	if mc.db, err = kvfile.NewStorage(filename); err != nil {
		Log("msg", "cannot open/create db", "file", filename, "error", err)
		mc.db = nil
	}
	return mc
}
func (mc *MimeCache) Close() error {
	if mc.db != nil {
		return mc.db.Close()
	}
	return nil
}