diff options
author | David A. Madore <david+git@madore.org> | 2014-10-09 20:40:26 +0200 |
---|---|---|
committer | David A. Madore <david+git@madore.org> | 2014-10-09 20:40:26 +0200 |
commit | cde90f22cc34b898c684c9de78c5e93022dbd42a (patch) | |
tree | 39cbca2edfa3acdfb640e64ca9ff3803fdcd08cc /org/madore/damlengine/WeblogSummary.java | |
parent | 827925b57dc5ba84e480cf9c66ff2cb13a096780 (diff) | |
download | damlengine-cde90f22cc34b898c684c9de78c5e93022dbd42a.tar.gz damlengine-cde90f22cc34b898c684c9de78c5e93022dbd42a.tar.bz2 damlengine-cde90f22cc34b898c684c9de78c5e93022dbd42a.zip |
Add a "dynamic context" global state, and make WeblogSummary stale when too old.
Diffstat (limited to 'org/madore/damlengine/WeblogSummary.java')
-rw-r--r-- | org/madore/damlengine/WeblogSummary.java | 7 |
1 files changed, 5 insertions, 2 deletions
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<Integer,EntrySummary> entries; + private long obtainedTime; private static WeblogSummary singleton; @@ -37,11 +38,13 @@ public final class WeblogSummary { this.entries = new HashMap<Integer,EntrySummary>(); } - 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"); |