mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
refactor: Update TTL configuration for completed jobs in InMemoryJobStore
- Changed the TTL for completed jobs from 5 minutes to 0, allowing for immediate cleanup. - Enhanced cleanup logic to respect the new TTL setting, improving resource management. - Updated comments for clarity on the behavior of the TTL configuration.
This commit is contained in:
parent
e01684a30a
commit
51c6d7ad8d
1 changed files with 7 additions and 4 deletions
|
|
@ -26,8 +26,8 @@ export class InMemoryJobStore implements IJobStore {
|
|||
private contentState = new Map<string, ContentState>();
|
||||
private cleanupInterval: NodeJS.Timeout | null = null;
|
||||
|
||||
/** Time to keep completed jobs before cleanup (5 minutes) */
|
||||
private ttlAfterComplete = 300000;
|
||||
/** Time to keep completed jobs before cleanup (0 = immediate) */
|
||||
private ttlAfterComplete = 0;
|
||||
|
||||
/** Maximum number of concurrent jobs */
|
||||
private maxJobs = 1000;
|
||||
|
|
@ -119,8 +119,11 @@ export class InMemoryJobStore implements IJobStore {
|
|||
|
||||
for (const [streamId, job] of this.jobs) {
|
||||
const isFinished = ['complete', 'error', 'aborted'].includes(job.status);
|
||||
if (isFinished && job.completedAt && now - job.completedAt > this.ttlAfterComplete) {
|
||||
toDelete.push(streamId);
|
||||
if (isFinished && job.completedAt) {
|
||||
// TTL of 0 means immediate cleanup, otherwise wait for TTL to expire
|
||||
if (this.ttlAfterComplete === 0 || now - job.completedAt > this.ttlAfterComplete) {
|
||||
toDelete.push(streamId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue