作业完成后未清除 WorkManager WorkName table
WorkManager WorkName table not being cleared after jobs complete
我正在通过调用 WorkManager.enqueueUniqueWork(String, ExistingWorkPolicy, OneTimeWorkRequest)
使用 WorkManager,我检查了磁盘上的数据库 androix.work.workdb
并注意到在 WorkName
table 中每个条目都有一个条目我开始的工作。工作完成后它们不会被删除。这是正常的吗?会自动清除吗?何时何人? (系统还是 WorkManager?)
这是正常的。 WorkManager 将完成的作业保存在其数据库中,以便您可以通过 getWorkInfosForUniqueWorkLiveData()
or other methods that give you the stats back (a fact pointed out by the keepResultsForAtLeast()
documentation 继续查询其 WorkInfo
。如果不是这种情况,您将永远无法知道您的作业是成功的、失败的还是被取消的。
You do not normally need to call this method - WorkManager takes care to auto-prune its work after a sane period of time
其中'a sane period of time',根据the source code目前设置为7天。
我正在通过调用 WorkManager.enqueueUniqueWork(String, ExistingWorkPolicy, OneTimeWorkRequest)
使用 WorkManager,我检查了磁盘上的数据库 androix.work.workdb
并注意到在 WorkName
table 中每个条目都有一个条目我开始的工作。工作完成后它们不会被删除。这是正常的吗?会自动清除吗?何时何人? (系统还是 WorkManager?)
这是正常的。 WorkManager 将完成的作业保存在其数据库中,以便您可以通过 getWorkInfosForUniqueWorkLiveData()
or other methods that give you the stats back (a fact pointed out by the keepResultsForAtLeast()
documentation 继续查询其 WorkInfo
。如果不是这种情况,您将永远无法知道您的作业是成功的、失败的还是被取消的。
You do not normally need to call this method - WorkManager takes care to auto-prune its work after a sane period of time
其中'a sane period of time',根据the source code目前设置为7天。