Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/cache/cache.go
2017-05-17 15:58:40 +10:00

34 lignes
737 o
Go

package cache
import (
"github.com/NyaaPantsu/nyaa/cache/memcache"
"github.com/NyaaPantsu/nyaa/cache/native"
"github.com/NyaaPantsu/nyaa/cache/nop"
"github.com/NyaaPantsu/nyaa/common"
"github.com/NyaaPantsu/nyaa/config"
"github.com/NyaaPantsu/nyaa/model"
)
// Cache defines interface for caching search results
type Cache interface {
Get(key common.SearchParam, r func() ([]model.Torrent, int, error)) ([]model.Torrent, int, error)
ClearAll()
}
// Impl cache implementation instance
var Impl Cache
func Configure(conf *config.CacheConfig) (err error) {
switch conf.Dialect {
case "native":
Impl = native.New(conf.Size)
return
case "memcache":
Impl = memcache.New()
return
default:
Impl = nop.New()
}
return
}