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

34 lignes
737 o
Go
Brut Vue normale Historique

2017-05-10 10:27:17 +02:00
package cache
import (
2017-05-17 07:58:40 +02:00
"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"
2017-05-10 10:27:17 +02:00
)
2017-05-11 15:01:53 +02:00
// 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()
2017-05-10 10:27:17 +02:00
}
2017-05-11 15:01:53 +02:00
// Impl cache implementation instance
var Impl Cache
2017-05-10 10:27:17 +02:00
func Configure(conf *config.CacheConfig) (err error) {
2017-05-11 15:01:53 +02:00
switch conf.Dialect {
case "native":
Impl = native.New(conf.Size)
return
case "memcache":
Impl = memcache.New()
return
2017-05-11 15:01:53 +02:00
default:
Impl = nop.New()
2017-05-10 10:27:17 +02:00
}
return
2017-05-10 10:27:17 +02:00
}