Skip to content

Conversation

@hoi
Copy link

@hoi hoi commented Jan 19, 2026

Summary

  • Add configurable TTL (Time-To-Live) for Redis task data to prevent unbounded memory growth
  • Task data automatically expires after 1 hour by default (configurable)
  • Supports runtime override via REDIS_TASK_TTL environment variable

Changes

Configuration

  • Added task_ttl_seconds to config.yml under redis section (default: 3600)
  • Added REDIS_TASK_TTL environment variable support for runtime override
  • Setting TTL to 0 disables automatic expiration

Implementation

  • Added get_redis_task_ttl() helper function in utils.py
  • Added hset_with_ttl() async helper in api.py for consistent TTL application
  • Updated all 8 Redis task storage calls to use TTL

Documentation

  • Updated config.yml with TTL documentation
  • Updated README.md with TTL configuration details

Test plan

  • Unit tests for get_redis_task_ttl() function (4 tests)
  • Unit tests for TTL environment variable override (3 tests)
  • Unit tests for hset_with_ttl() behavior (4 tests)
  • Unit tests for config documentation (2 tests)
  • All 13 tests pass

Add automatic expiration for task data stored in Redis to prevent
unbounded memory growth over time.

Changes:
- Add task_ttl_seconds config option (default: 3600s / 1 hour)
- Add REDIS_TASK_TTL environment variable override
- Add hset_with_ttl helper for consistent TTL application
- Apply TTL to all task data (crawl jobs, LLM extraction)
- Add 13 unit tests for TTL functionality
- Update documentation with TTL configuration details

Setting TTL to 0 disables automatic expiration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants