ad3a44e2f8
* Torznab fix Added multiple category search Fixed issues in #1017 Now category from searchParam & torrentParam are arrays of category New Struct Categories * Fix travis error due to database code
33 lignes
698 o
Go
33 lignes
698 o
Go
package cache
|
|
|
|
import (
|
|
"github.com/NyaaPantsu/nyaa/cache/memcache"
|
|
"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
|
|
}
|