dbs

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppConfigCacheKey added in v1.2.4

func AppConfigCacheKey(app string) string

AppConfigCacheKey 返回某 app 的配置缓存键(正/负缓存共用)

Types

type AppConfig added in v1.2.4

type AppConfig struct{}

AppConfig 应用配置仓储实现(Redis 缓存 + 延迟双删)

func NewAppConfig added in v1.2.4

func NewAppConfig() *AppConfig

NewAppConfig 取应用配置仓储单例

func (AppConfig) CreateAppConfig added in v1.2.4

func (r AppConfig) CreateAppConfig(ctx core.Context, ent *entity.AppConfig) (uint32, error)

CreateAppConfig 创建应用配置。

func (AppConfig) GetAppConfig added in v1.2.4

func (r AppConfig) GetAppConfig(ctx core.Context, app string) (*entity.AppConfig, error)

GetAppConfig 读配置:Redis 优先;miss 时抢重建锁回源并回填。

func (AppConfig) ListAppConfig added in v1.2.4

func (r AppConfig) ListAppConfig(ctx core.Context, req *types.ListAppConfigRequest) ([]*entity.AppConfig, uint32, error)

ListAppConfig 分页查询应用配置

func (AppConfig) RecalcUsage added in v1.2.4

func (r AppConfig) RecalcUsage(ctx core.Context, app string) (uint64, error)

RecalcUsage 按逻辑口径重算 used_bytes(Σ 该 app 每个 file 行引用 object 的 size),失效缓存后回查。

func (AppConfig) ReleaseQuota added in v1.2.4

func (r AppConfig) ReleaseQuota(ctx core.Context, app string, size uint64) error

ReleaseQuota 归还配额:used_bytes -= size,IF 夹 0 防无符号下溢。

func (AppConfig) ReserveQuota added in v1.2.4

func (r AppConfig) ReserveQuota(ctx core.Context, app string, size uint64) (bool, error)

ReserveQuota 原子占用配额:单条 CAS 既校验又自增(防并发绕过)。rowsAffected==1 即占用成功。

func (AppConfig) UpdateAppConfig added in v1.2.4

func (r AppConfig) UpdateAppConfig(ctx core.Context, ent *entity.AppConfig) error

UpdateAppConfig 局部更新行并执行延迟双删(零值可写列在 entity 里是指针,非 nil 即写入;不得被 ctx.Transaction 包裹)。

type Directory

type Directory struct{}

Directory 目录仓储实现(物化路径)

func NewDirectory

func NewDirectory() *Directory

NewDirectory 取目录仓储单例

func (Directory) CreateDirectoryIgnore added in v1.2.4

func (r Directory) CreateDirectoryIgnore(ctx core.Context, ent *entity.Directory) (*entity.Directory, error)

CreateDirectoryIgnore 幂等新建,返回最终行。

func (Directory) DeleteDirectoryTree added in v1.2.4

func (r Directory) DeleteDirectoryTree(ctx core.Context, app string, id uint32, path string) error

DeleteDirectoryTree 删子树:一条语句删掉自己与全部后代

func (Directory) GetDirectory

func (r Directory) GetDirectory(ctx core.Context, app string, id uint32) (*entity.Directory, error)

GetDirectory 按主键查询目录(必须带 app 限定)

func (Directory) GetDirectoryById added in v1.2.4

func (r Directory) GetDirectoryById(ctx core.Context, id uint32) (*entity.Directory, error)

GetDirectoryById 按主键查询目录(不限定 app,用于从目录派生 app 等读场景)

func (Directory) GetDirectoryByPath added in v1.2.4

func (r Directory) GetDirectoryByPath(ctx core.Context, app, path string) (*entity.Directory, error)

GetDirectoryByPath 按路径查询目录

func (Directory) ListDirectory

func (r Directory) ListDirectory(ctx core.Context, app string) ([]*entity.Directory, error)

ListDirectory 全量取回某 app 的目录

func (Directory) ListDirectoryInPaths added in v1.2.4

func (r Directory) ListDirectoryInPaths(ctx core.Context, app string, paths []string) ([]*entity.Directory, error)

ListDirectoryInPaths 按路径集合批量查询

func (Directory) MoveDirectory added in v1.2.4

func (r Directory) MoveDirectory(ctx core.Context, p *types.MoveDirectoryParams) error

MoveDirectory 移动子树:一条 UPDATE 重写整棵子树 path,并把 updated_at/updated_by 刷到本次操作。

func (Directory) UpdateDirectory

func (r Directory) UpdateDirectory(ctx core.Context, ent *entity.Directory) error

UpdateDirectory 按主键+app 更新目录实体。零值可写列(accept)在 entity 里是指针,非 nil 即写入,直接 Updates(ent)。

type File

type File struct{}

File 业务文件条目仓储实现

func NewFile

func NewFile() *File

NewFile 取业务文件仓储单例

func (File) CreateFile

func (r File) CreateFile(ctx core.Context, ent *entity.File) (uint32, error)

CreateFile 新建文件

func (File) DeleteFile

func (r File) DeleteFile(ctx core.Context, id uint32) error

DeleteFile 删除文件行

func (File) DeleteFilesByStatus added in v1.2.4

func (r File) DeleteFilesByStatus(ctx core.Context, status uint8, limit int) (int64, error)

DeleteFilesByStatus 后台回收:按状态分批硬删 file 行(ORDER BY id LIMIT limit),返回删除行数。

func (File) GetFile

func (r File) GetFile(ctx core.Context, id uint32) (*entity.File, error)

GetFile 按主键查正常文件(status=1)

func (File) GetFileByUploadId

func (r File) GetFileByUploadId(ctx core.Context, uploadID string) (*entity.File, error)

GetFileByUploadId 按 upload_id 查文件(幂等收口 / 召回复用)。

func (File) ListFileByDirectory added in v1.2.4

func (r File) ListFileByDirectory(ctx core.Context, app string, directoryID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)

ListFileByDirectory 目录内分页(仅 status=1,走 idx_file_app_directory)。

func (File) ListFileByUser added in v1.2.4

func (r File) ListFileByUser(ctx core.Context, app string, userID uint32, req *types.PageRequest) ([]*entity.File, uint32, error)

ListFileByUser "我的文件"分页(仅 status=1,走 idx_file_app_user)。

func (File) MarkDeleteInSubtree added in v1.2.4

func (r File) MarkDeleteInSubtree(ctx core.Context, app string, id uint32, path string) (int64, error)

MarkDeleteInSubtree 软删:子树(含自身目录)下 status=1 的 file 行标为待删除(2)。前缀谓词必须转义,口径须与 directory 树一致。

func (File) UpdateFile

func (r File) UpdateFile(ctx core.Context, ent *entity.File) error

UpdateFile 改名 / 移动(name 非空 / directory_id 非 0 才落列,零值自动跳过;updated_at 由 gorm 自动填)。

type Object added in v1.2.4

type Object struct{}

Object 物理对象(内容寻址)仓储实现

func NewObject added in v1.2.4

func NewObject() *Object

NewObject 取物理对象仓储单例

func (Object) CreateObject added in v1.2.4

func (r Object) CreateObject(ctx core.Context, ent *entity.Object) (*entity.Object, error)

CreateObject 幂等新建;撞 uidx_object_store_md5 时重查复用赢家,返回最终行。

func (Object) DeleteObject added in v1.2.4

func (r Object) DeleteObject(ctx core.Context, id uint32) error

DeleteObject 删除对象行(桶对象由调用方另行处理)。

func (Object) DeleteObjectIfUnreferenced added in v1.2.4

func (r Object) DeleteObjectIfUnreferenced(ctx core.Context, objectID uint32) (bool, error)

DeleteObjectIfUnreferenced 零引用才删行;返回 true 表示已删除。

func (Object) ExistsObject added in v1.2.4

func (r Object) ExistsObject(ctx core.Context, storeKeyword, md5 string) (bool, error)

ExistsObject 存在性判断(按 store_keyword + md5)。

func (Object) GetObject added in v1.2.4

func (r Object) GetObject(ctx core.Context, id uint32) (*entity.Object, error)

GetObject 按主键查对象

func (Object) GetObjectByMd5 added in v1.2.4

func (r Object) GetObjectByMd5(ctx core.Context, storeKeyword, md5 string) (*entity.Object, error)

GetObjectByMd5 按 (store_keyword, md5) 查对象;查不到即 gorm.ErrRecordNotFound。

func (Object) GetObjectByMd5Any added in v1.2.4

func (r Object) GetObjectByMd5Any(ctx core.Context, md5 string) (*entity.Object, error)

GetObjectByMd5Any 按 md5 全局查对象(不限定存储,取最早入库一条;内容寻址,同 md5 内容一致)。

func (Object) IsReferenced added in v1.2.4

func (r Object) IsReferenced(ctx core.Context, objectID uint32) (bool, error)

IsReferenced 引用判定:file 表是否仍存在指向该对象的行。

func (Object) ListObjectByIDs added in v1.2.4

func (r Object) ListObjectByIDs(ctx core.Context, ids []uint32) ([]*entity.Object, error)

ListObjectByIDs 主键批量查对象(列表出 URL 用,不入逐行点查)。

func (Object) ScanUnreferenced added in v1.2.4

func (r Object) ScanUnreferenced(ctx core.Context, afterID uint32, limit int) ([]*entity.Object, error)

ScanUnreferenced 按主键区间分批扫零引用行(离线核对)。

type Store added in v1.2.4

type Store struct {
	// contains filtered or unexported fields
}

Store 存储后端仓储实现(store 行走 pkg/cache:内存读 + Redis 跨节点同步)。

func NewStore added in v1.2.4

func NewStore() *Store

NewStore 取存储后端仓储单例(首次调用注册 BeforeStart 钩子,启动前全量灌入 store 缓存)。

func (Store) CreateStore added in v1.2.4

func (r Store) CreateStore(ctx core.Context, ent *entity.Store) (uint32, error)

CreateStore 新建存储后端(DB 写入与缓存 Put 同事务)。

func (Store) GetClient added in v1.2.4

func (r Store) GetClient(keyword string) (repository.Client, bool)

GetClient 取厂商客户端(缓存读行→按行指针记忆化构造,读路径零网络跳)。

func (Store) GetStore added in v1.2.4

func (r Store) GetStore(ctx core.Context, id uint32) (*entity.Store, error)

GetStore 按主键查询存储后端

func (Store) GetStoreByKeyword added in v1.2.4

func (r Store) GetStoreByKeyword(ctx core.Context, keyword string) (*entity.Store, error)

GetStoreByKeyword 按 keyword 取存储后端(含 status,用于启用态判定)

func (Store) ListClients added in v1.2.4

func (r Store) ListClients() []repository.Client

ListClients 取全部客户端(GC / 离线核对遍历用)。

func (Store) ListStore added in v1.2.4

func (r Store) ListStore(ctx core.Context, req *types.ListStoreRequest) ([]*entity.Store, uint32, error)

ListStore 分页查询存储后端

func (Store) UpdateStore added in v1.2.4

func (r Store) UpdateStore(ctx core.Context, ent *entity.Store) error

UpdateStore 局部更新(service 已读当前行并叠加传入字段;零值可写列如 status 在 entity 用指针,Updates 不跳过)。 写回后重取权威行(含最新时间戳)Put 进缓存,与 DB 写同事务。

type Upload added in v1.2.4

type Upload struct{}

Upload 分片上传会话仓储实现

func NewUpload added in v1.2.4

func NewUpload() *Upload

NewUpload 取分片上传会话仓储单例

func (Upload) CreateUpload added in v1.2.4

func (r Upload) CreateUpload(ctx core.Context, ent *entity.Upload) (uint32, error)

CreateUpload 建会话

func (Upload) DeleteUpload added in v1.2.4

func (r Upload) DeleteUpload(ctx core.Context, id uint32) error

DeleteUpload 删会话

func (Upload) GetUpload added in v1.2.4

func (r Upload) GetUpload(ctx core.Context, uploadID string, userID uint32) (*entity.Upload, error)

GetUpload 命中会话;必须带 user_id 做鉴权,查不到即"会话不存在"。

func (Upload) GetUploadByKey added in v1.2.4

func (r Upload) GetUploadByKey(ctx core.Context, key *types.UploadKey) (*entity.Upload, error)

GetUploadByKey 按会话身份 (store_keyword, md5, user_id, directory_id) 召回在飞会话。

func (Upload) ListExpiredUpload added in v1.2.4

func (r Upload) ListExpiredUpload(ctx core.Context, before int64, limit int) ([]*entity.Upload, error)

ListExpiredUpload 扫过期会话(GC 用),按 updated_at 升序。

func (Upload) TouchUpload added in v1.2.4

func (r Upload) TouchUpload(ctx core.Context, id uint32) error

TouchUpload 顶 updated_at(滑动过期时钟)。显式写列,不依赖空 map 触发自动时间戳。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL