2021-12-06 09:49:20 +00:00
|
|
|
package base
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/Xhofe/alist/conf"
|
|
|
|
"github.com/Xhofe/alist/model"
|
|
|
|
"github.com/Xhofe/alist/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
func KeyCache(path string, account *model.Account) string {
|
|
|
|
path = utils.ParsePath(path)
|
|
|
|
return fmt.Sprintf("%s%s", account.Name, path)
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetCache(path string, obj interface{}, account *model.Account) error {
|
|
|
|
return conf.Cache.Set(conf.Ctx, KeyCache(path, account), obj, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetCache(path string, account *model.Account) (interface{}, error) {
|
2021-12-08 14:44:45 +00:00
|
|
|
return conf.Cache.Get(conf.Ctx, KeyCache(path, account))
|
2021-12-06 09:49:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func DeleteCache(path string, account *model.Account) error {
|
2021-12-08 14:44:45 +00:00
|
|
|
return conf.Cache.Delete(conf.Ctx, KeyCache(path, account))
|
2021-12-06 09:49:20 +00:00
|
|
|
}
|