entur / lamassu

Mobility hub
European Union Public License 1.2
5 stars 7 forks source link

Inconsistent TTL used for feed cache #482

Closed testower closed 3 weeks ago

testower commented 3 weeks ago

The feed cache updaters (https://github.com/entur/lamassu/blob/master/src/main/java/org/entur/lamassu/leader/feedcachesupdater/V3FeedCachesUpdater.java and https://github.com/entur/lamassu/blob/master/src/main/java/org/entur/lamassu/leader/feedcachesupdater/V2FeedCachesUpdater.java) have two methods for updating the feed caches: updateFeedCaches and getAndUpdateFeedCache.

They should be identical in behavior, except the latter also returns the value that was previously held in the cache before the update. However, they behave differently with respect to the ttl value that is set on the updated value.

updateFeedCaches uses the ttl from the feed itself, along with a configurable minimum value plus a configurable padding, to determine the ttl used for the cache. The idea is that the configurable minimum will account for some providers using unreasonably low ttl values for non-realtime feeds, whereas the configurable padding will account for the delay between updates (the feed update interval).

getAndUpdateFeedCache has the same logic, except it also uses a static minimum in addition to the configurable one, whichever is larger. This minimum is hardcoded to 24 hours.

This hard-coded minimum should be removed so that the behavior is the same across these two methods.