mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-12 16:26:36 +08:00
优化
This commit is contained in:
@@ -45,6 +45,9 @@ type SchedulerService struct {
|
||||
|
||||
// readerContentCleaner 阅读正文缓存的清理钩子(由阅读模块注入)。
|
||||
readerContentCleaner func(context.Context)
|
||||
// readerFilesTTLHours 书源文件缓存(java.cacheFile / downloadFile)的保留小时数。
|
||||
// 0 表示用内置兜底值(见 readerFilesRetentionMax)。
|
||||
readerFilesTTLHours int
|
||||
|
||||
segments *MediaSegmentService
|
||||
|
||||
@@ -96,6 +99,11 @@ func (s *SchedulerService) SetReaderContentCleaner(fn func(context.Context)) {
|
||||
s.readerContentCleaner = fn
|
||||
}
|
||||
|
||||
// SetReaderFilesTTL 配置书源文件缓存的保留小时数(0 表示用兜底值)。
|
||||
func (s *SchedulerService) SetReaderFilesTTL(hours int) {
|
||||
s.readerFilesTTLHours = hours
|
||||
}
|
||||
|
||||
// scheduledJob is one recurring task.
|
||||
type scheduledJob struct {
|
||||
name string
|
||||
@@ -165,6 +173,12 @@ func (s *SchedulerService) Start(ctx context.Context) {
|
||||
interval: 1 * time.Hour,
|
||||
run: s.jobCleanReaderContentCache,
|
||||
})
|
||||
// 书源文件缓存与孤儿临时文件的清理和正文缓存同源,一起注册。
|
||||
s.jobs = append(s.jobs, &scheduledJob{
|
||||
name: "reader_files_cleanup",
|
||||
interval: 24 * time.Hour,
|
||||
run: s.jobCleanReaderFiles,
|
||||
})
|
||||
}
|
||||
// 片头预热只在注入了 Segments 时注册,避免测试跑无转外网任务。
|
||||
if s.segments != nil {
|
||||
|
||||
Reference in New Issue
Block a user