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
707 o
Go
Brut Vue normale Historique

2017-05-10 10:27:17 +02:00
package cache
import (
2017-05-11 15:01:53 +02:00
"github.com/ewhal/nyaa/cache/memcache"
"github.com/ewhal/nyaa/cache/native"
"github.com/ewhal/nyaa/cache/nop"
2017-05-10 11:03:49 +02:00
"github.com/ewhal/nyaa/common"
2017-05-11 15:01:53 +02:00
"github.com/ewhal/nyaa/config"
2017-05-10 10:27:17 +02:00
"github.com/ewhal/nyaa/model"
)
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
}