- if (!lastSearch.isEmpty())
- {
- cacheComboBox.setSelectedItem(lastSearch);
- cacheComboBox.requestFocus();
- }
- else
+ /**
+ * Method for deleting cached items for a given cache key
+ *
+ * @param cacheKey
+ * the cache key
+ */
+ public void deleteCacheItems(String cacheKey)
+ {
+ cacheItems.put(cacheKey, new LinkedHashSet<String>());
+ persistCache(cacheKey);
+ }
+
+ /**
+ * Method for obtaining the preset maximum cache limit for a given cache key
+ *
+ * @param cacheKey
+ * the cache key
+ * @return the max number of items that could be cached
+ */
+ public String getCacheLimit(String cacheKey)
+ {
+ String uniqueKey = cacheKey + DEFAULT_LIMIT_KEY;
+ return Cache.getDefault(uniqueKey, DEFAULT_LIMIT);
+ }
+
+ /**
+ * Method for updating the preset maximum cache limit for a given cache key
+ *
+ * @param cacheKey
+ * the cache key
+ * @param newLimit
+ * the max number of items that could be cached for the given cache
+ * key
+ * @return
+ */
+ public int updateCacheLimit(String cacheKey, int newUserLimit)
+ {
+ String newLimit = String.valueOf(newUserLimit);
+ String uniqueKey = cacheKey + DEFAULT_LIMIT_KEY;
+ String formerLimit = getCacheLimit(cacheKey);
+ if (newLimit != null && !newLimit.isEmpty()
+ && !formerLimit.equals(newLimit))