'Redis cache role to persist until new result

I'm trying help a team to think a role to Redis to persist a cache, but my knowledge about it is limited.

Today we have 18 entities that other systems update the informations in diferente times.

Our system mount a unique entity to return to user using some entities according with users configuration.

So, when a user make a request we get some entities, cache them separately and mount a new entity to return.

If other user request other entities together with cached entity, we get the cache and request the new entities and make a cache of them.

So, the problem is when cache expire, if one user try get some entities and the cache is empty the process restart.

The ideia is persist the caches of each entity and from time to time our system check if there are new elements on each entities, update cache, and when one user request the content always get from the cache.

But we are trying avoid use a system like cron or a timer to verify if there is a new element in each entities.

The question is there a way to know if redis know if the cache will expire soon and fire an event to our system request the entity again or is there a way to redis persist a cache until some entity have a change?

PS: Our system is Python.

Regards.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source