🎨 abstract cache method

This commit is contained in:
微凉
2021-12-08 22:58:44 +08:00
parent bb6e520ab5
commit b36eaf08f0
8 changed files with 18 additions and 19 deletions

View File

@ -154,7 +154,7 @@ func (driver Onedrive) File(path string, account *model.Account) (*model.File, e
func (driver Onedrive) Files(path string, account *model.Account) ([]model.File, error) {
path = utils.ParsePath(path)
cache, err := conf.Cache.Get(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path))
cache, err := base.GetCache(path, account)
if err == nil {
files, _ := cache.([]model.File)
return files, nil
@ -168,7 +168,7 @@ func (driver Onedrive) Files(path string, account *model.Account) ([]model.File,
files = append(files, *driver.FormatFile(&file))
}
if len(files) > 0 {
_ = conf.Cache.Set(conf.Ctx, fmt.Sprintf("%s%s", account.Name, path), files, nil)
_ = base.SetCache(path, files, account)
}
return files, nil
}