X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fcache%2FAppCache.java;h=8ed33e692ca1a2839165573b52280c93ebbb239c;hb=53e3890428beabca3cdb44b90ad8e1c294d58768;hp=9f9a25b37c2b3d9c3d01ae5675e223dc8e82dca1;hpb=221f613b5d235a11c602b989598afe97b5b7b203;p=jalview.git diff --git a/src/jalview/io/cache/AppCache.java b/src/jalview/io/cache/AppCache.java index 9f9a25b..8ed33e6 100644 --- a/src/jalview/io/cache/AppCache.java +++ b/src/jalview/io/cache/AppCache.java @@ -20,6 +20,10 @@ public class AppCache private Hashtable> cacheItems; + private static final String DEFAULT_LIMIT_KEY = ".DEFAULT_LIMIT"; + + private static final String DEFAULT_LIMIT = "99"; + private static final String CACHE_DELIMITER = ";"; private AppCache() @@ -115,6 +119,25 @@ public class AppCache persistCache(cacheKey); } + public String getCacheLmit(String cacheKey) + { + String uniqueKey = cacheKey + DEFAULT_LIMIT_KEY; + return Cache.getDefault(uniqueKey, DEFAULT_LIMIT); + } + + public int updateCacheLimit(String cacheKey, String newLimit) + { + String uniqueKey = cacheKey + DEFAULT_LIMIT_KEY; + String formerLimit = getCacheLmit(cacheKey); + if (newLimit != null && !newLimit.isEmpty() + && !formerLimit.equals(newLimit)) + { + Cache.setProperty(uniqueKey, newLimit); + formerLimit = newLimit; + } + return Integer.valueOf(formerLimit); + } + /** * Method for inserting cache items for given cache key into the cache data * structure