From 0ef902621dc6672d50b727a2b6e7b3f5e750baca Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Thu, 15 Mar 2018 09:55:48 +0200 Subject: [PATCH] MXS-1475 Update cache entry if originally present In case the entry in the cache can not be used because the hard TTL has kicked in, we fetch the data and update the cache irrespected of the value if @maxscale.cache.populate. That way an entry that once was put in the cache, will remain in the cache (as long as there is space). --- server/modules/filter/cache/cachefiltersession.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/modules/filter/cache/cachefiltersession.cc b/server/modules/filter/cache/cachefiltersession.cc index 3b81197c9..992cd446a 100644 --- a/server/modules/filter/cache/cachefiltersession.cc +++ b/server/modules/filter/cache/cachefiltersession.cc @@ -1080,7 +1080,11 @@ CacheFilterSession::routing_action_t CacheFilterSession::route_SELECT(cache_acti if (routing_action == ROUTING_CONTINUE) { - if (m_populate || m_refreshing) + // If we are populating or refreshing, or the result was discarded + // due to hard TTL having kicked in, then we fetch the result *and* + // update the cache. That is, as long as there is room in the cache + // an entry will stay there. + if (m_populate || m_refreshing || CACHE_RESULT_IS_DISCARDED(result)) { m_state = CACHE_EXPECTING_RESPONSE; }