You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

cache.go 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package rpc
  2. import (
  3. "context"
  4. "fmt"
  5. "gitlink.org.cn/cloudream/common/consts/errorcode"
  6. clitypes "gitlink.org.cn/cloudream/jcs-pub/client/types"
  7. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
  8. hubrpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc/hub"
  9. )
  10. func (svc *Service) CheckCache(context context.Context, msg *hubrpc.CheckCache) (*hubrpc.CheckCacheResp, *rpc.CodeError) {
  11. store, err := svc.stgPool.GetShardStore(&msg.UserSpace)
  12. if err != nil {
  13. return nil, rpc.Failed(errorcode.OperationFailed, fmt.Sprintf("get shard store of user space %v: %v", msg.UserSpace, err))
  14. }
  15. infos, err := store.ListAll()
  16. if err != nil {
  17. return nil, rpc.Failed(errorcode.OperationFailed, fmt.Sprintf("listting file in shard store: %v", err))
  18. }
  19. var fileHashes []clitypes.FileHash
  20. for _, info := range infos {
  21. fileHashes = append(fileHashes, info.Hash)
  22. }
  23. return &hubrpc.CheckCacheResp{FileHashes: fileHashes}, nil
  24. }
  25. func (svc *Service) CacheGC(context context.Context, msg *hubrpc.CacheGC) (*hubrpc.CacheGCResp, *rpc.CodeError) {
  26. store, err := svc.stgPool.GetShardStore(&msg.UserSpace)
  27. if err != nil {
  28. return nil, rpc.Failed(errorcode.OperationFailed, fmt.Sprintf("get shard store of user space %v: %v", msg.UserSpace, err))
  29. }
  30. err = store.GC(msg.Availables)
  31. if err != nil {
  32. return nil, rpc.Failed(errorcode.OperationFailed, fmt.Sprintf("purging cache: %v", err))
  33. }
  34. return &hubrpc.CacheGCResp{}, nil
  35. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。