Changeset 10087 in josm for trunk


Ignore:
Timestamp:
2016-03-30T20:18:14+02:00 (8 years ago)
Author:
wiktorn
Message:

Make minimum and maximum cache expires for imagery adjustable

Location:
trunk/src/org/openstreetmap/josm/data
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r9232 r10087  
    3030import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
    3131import org.openstreetmap.josm.data.cache.JCSCachedTileLoaderJob;
     32import org.openstreetmap.josm.data.preferences.LongProperty;
    3233import org.openstreetmap.josm.tools.HttpClient;
    3334
     
    4041public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener  {
    4142    private static final Logger LOG = FeatureAdapter.getLogger(TMSCachedTileLoaderJob.class.getCanonicalName());
    42     private static final long MAXIMUM_EXPIRES = 30 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/;
    43     private static final long MINIMUM_EXPIRES = 1 /*hour*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/;
     43    private static final LongProperty MAXIMUM_EXPIRES = new LongProperty("imagery.generic.maximum_expires",
     44            30 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
     45    private static final LongProperty MINIMUM_EXPIRES = new LongProperty("imagery.generic.minimum_expires",
     46            1 /*hour*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/);
    4447    private final Tile tile;
    4548    private volatile URL url;
     
    244247        // keep the expiration time between MINIMUM_EXPIRES and MAXIMUM_EXPIRES, so we will cache the tiles
    245248        // at least for some short period of time, but not too long
    246         if (ret.getExpirationTime() < now + MINIMUM_EXPIRES) {
    247             ret.setExpirationTime(now + MINIMUM_EXPIRES);
    248         }
    249         if (ret.getExpirationTime() > now + MAXIMUM_EXPIRES) {
    250             ret.setExpirationTime(now + MAXIMUM_EXPIRES);
     249        if (ret.getExpirationTime() < now + MINIMUM_EXPIRES.get()) {
     250            ret.setExpirationTime(now + MINIMUM_EXPIRES.get());
     251        }
     252        if (ret.getExpirationTime() > now + MAXIMUM_EXPIRES.get()) {
     253            ret.setExpirationTime(now + MAXIMUM_EXPIRES.get());
    251254        }
    252255        return ret;
Note: See TracChangeset for help on using the changeset viewer.