InMemoryTimerStore (default)
-
Description
InMemoryTimerStoreis the default timer store and it stores timers in memory. Suitable for development and testing as timers are lost on server restart. -
Configuration
To use the
InMemoryTimerStoreno configuration is needed.
RedisTimerStore
Description
RedisTimerStore maintains conversation timers using Redis as a persistence layer. This is the recommended option for production deployments as it supports persistence across server restarts and works in multi-pod environments.
With Redis:
- Timers survive server restarts.
- All pods in a horizontally-scaled deployment share the same timer state.
- Timers that expired while the server was down are recovered and processed on startup.
Configuration
To set up the timer store with Redis the following steps are required:- Add required configuration to your
endpoints.yml
Fallback Timer Store
If Redis is configured but becomes unavailable, Rasa automatically falls back to theInMemoryTimerStore.
Sessions continue to be managed without crashing, and a warning is logged when the fallback is activated.
When Redis recovers, Rasa resumes using it and logs that the fallback has been deactivated.
Custom Timer Stores
If you need a timer store which is not available out of the box, you can implement your own. To write a custom timer store, extendSessionTimerStore from rasa.core.timer_stores.timer_store.
Your constructor must accept an endpoint_config parameter:
close: releases any resources (connections, file handles, etc.) held by the store. Must respect the following signature:
store_timer: persists a timer entry for a conversation. Must respect the following signature:
delete_timer: removes a timer entry. Must respect the following signature:
get_timer: retrieves the current timer for a conversation, or None if none exists. Must respect the following signature:
get_expired_timers: returns all timers whosescheduled_timeis at or beforecutoff_time. Must respect the following signature:
get_expired_timers method:
_check_time_for_expired(cutoff_time): returnscutoff_timeif set, otherwisetime.time()._filter_expired(timers, check_time): filters an iterable ofSessionTimerobjects to those withscheduled_time <= check_time.
SessionTimer.create_timer(sender_id, session_id, scheduled_time, metadata): constructs aSessionTimerfrom the arguments passed tostore_timer.
Configuration
Put the module path to your custom timer store class inendpoints.yml under the timer_store key.
Any additional fields are passed through as part of the EndpointConfig and are accessible via endpoint_config.kwargs:
endpoints.yml