Manage workflow data expiration and TTL
masterBy default, Gush and Redis keep workflow data indefinitely. To prevent Redis from growing too large, you should implement a TTL (Time To Live) strategy.
1. Set a global TTL
Configure a global expiration time in seconds via config.ttl. It is recommended to set this to a duration of approximately one week rather than very short intervals.
2. Purge expired data
Setting the TTL is not enough; you must periodically call Client#expire_workflows to actually clear the expired stored workflow data, job data, and indexes. It is recommended to call this at least once for every 1000 workflows created.
3. Individual workflow expiration
If you need granular control, you can call flow.expire!(ttl) on a specific workflow instance. Passing -1 will prevent the workflow from ever expiring.
# config/initializers/gush.rb
Gush.configure do |config|
config.redis_url = "redis://localhost:6379"
config.concurrency = 5
config.ttl = 3600*24*7 # Example: 1 week in seconds
end
# Periodically run this to clear expired data
Gush::Client.new.expire_workflows