How to have a database sync at midnight for the entire rasa server not one single session

Hi, I am using python’s functools lru_cache(https://docs.python.org/3/library/functools.html#functools.lru_cache )decorator with maxsize = 1 to cache a database query in one function that will be called from a custom action.
At midnight everyday I want to call this function. so that database query is executed and stored in cache for day use.
my lru_cache function is:\

@lru_cache(maxsize = 1)
def call_database(day):
database query
return query_resutl.\

The way it is called in custom action is:
day = datetime.now().day
return_value=call_database(day)\

how to call call_database function at midnight everyday without session and user_query in rasa actions.

is there any daemon thread kind of thing in rasa. That we can use to run this kind of tasks like database syncup at midnight???..

You could use an external event although I’m not sure if this will work since the event would not be assocated with a session. I suspect it will still work but you could also save a session id from one of your own conversations.

1 Like

actually what i am doing there is storing database query result in lru_cache. and I want to sync(call) the database query in the midnight everyday. So, the changes in the database will reflect in cache also. without the need of user conversing with the chatbot and it is not related to User conversations. It should be automatically done in the backend like some other database sync up in python.

Is there any way to do this in rasa. or is there any way to cache some database query result in rasa without lru_cache and do sync operations every midnight.