@@ -0,0 +1,1882 @@
+package uk.ac.ebi.quickgo.rest.cache;%0A%0Aimport java.time.Duration;%0Aimport java.time.LocalTime;%0Aimport java.util.function.Supplier;%0A%0A/**%0A * This algorithm models the following situation - Start time of caching before end time. So the start and end of%0A * caching occurs in one day. Here are the situations this class must deal with%0A *%0A * After Start Time Before End Time: Re-indexing is not going to take place until after End time. Give clients the time%0A * in seconds until End Time will be reached.%0A *%0A * After End Time and before Start Time: We are around the indexing time. We tell all respondents not to cache - max%0A * age is set to zero.%0A *%0A * See %3Ca href=%22https://jakearchibald.com/2016/caching-best-practices/%22%3ECaching best practices & max-age%0A * gotchas%3C/a%3E,%0A * %3Ca href=%22https://www.mnot.net/cache_docs/%22%3ECaching Tutorial for Web Authors and Webmasters%3C/a%3E,%0A * %3Ca href=%22https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers%22%3EIncreasing Application Performance with HTTP Cache Headers %7C Heroku Dev Center%3C/a%3E%0A *%0A * @return a String that holds the number of seconds left before the cut-off time after which requests will not be%0A * cached.%0A * @author Tony Wardell%0A * Date: 10/04/2017%0A * Time: 15:47%0A * Created with IntelliJ IDEA.%0A */%0Apublic class MaxAgeWhenStartBeforeEndTime implements Supplier%3CDuration%3E%7B%0A%0A    private LocalTime start, end;%0A%0A    public MaxAgeWhenStartBeforeEndTime(LocalTime start, LocalTime end) %7B%0A        this.start = start;%0A        this.end = end;%0A    %7D%0A%0A    @Override public Duration get() %7B%0A        Duration remaining;%0A        final LocalTime now = LocalTime.now();%0A        if (now.isAfter(start) && now.isBefore(end)) %7B%0A            remaining = Duration.between(now, end);%0A        %7D else %7B%0A            remaining = Duration.ZERO;%0A        %7D%0A        assert !remaining.isNegative();%0A        return remaining;%0A    %7D%0A%7D%0A

Create a class to hold max age calculation when start and end time for caching availability is in the same day.