From cde90f22cc34b898c684c9de78c5e93022dbd42a Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Thu, 9 Oct 2014 20:40:26 +0200 Subject: Add a "dynamic context" global state, and make WeblogSummary stale when too old. --- org/madore/damlengine/WeblogSummary.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'org/madore/damlengine/WeblogSummary.java') diff --git a/org/madore/damlengine/WeblogSummary.java b/org/madore/damlengine/WeblogSummary.java index b067987..4f560e8 100644 --- a/org/madore/damlengine/WeblogSummary.java +++ b/org/madore/damlengine/WeblogSummary.java @@ -30,6 +30,7 @@ public final class WeblogSummary { } public HashMap entries; + private long obtainedTime; private static WeblogSummary singleton; @@ -37,11 +38,13 @@ public final class WeblogSummary { this.entries = new HashMap(); } - public static synchronized WeblogSummary getSummary() { - if ( singleton != null ) + public static synchronized WeblogSummary getSummary(Context.DynamicContext dc) { + if ( singleton != null + && ( dc == null || singleton.obtainedTime < dc.modTime ) ) return singleton; singleton = new WeblogSummary(); try { + singleton.obtainedTime = System.currentTimeMillis(); final Connection conn = WeblogDatabaseConnection.getConnection(); final PreparedStatement selSt = conn.prepareStatement("SELECT id , edate , lang , title , title_xml , do_single_page FROM entries"); -- cgit v1.2.3