@Test @Order(3) void deleteValueFromCache() { assertDoesNotThrow(() -> assertNull(cache().deleteFromCache("non_existent_key"), "Deleting non-existent key should not have a value"), "Delete from cache threw an exception"); assertDoesNotThrow(() -> assertEquals(testVal, cache().deleteFromCache(testKey), "Value from deleted key did not match"), "Delete from cache threw an exception"); }
@Override public String deleteFromCache(String key) throws CacheStoreException { Objects.requireNonNull(key, Utils.getMessage("IMG-0066")); if (Constants.CACHE_DIR_KEY.equalsIgnoreCase(key)) { return properties.getProperty(Constants.CACHE_DIR_KEY, null); } String oldValue = (String) properties.remove(key.toLowerCase()); if (oldValue != null) { persistToDisk(); } return oldValue; }
FileCacheStore implements CacheStore { @Override public String deleteFromCache(String key) throws CacheStoreException { Objects.requireNonNull(key, Utils.getMessage("IMG-0066")); if (Constants.CACHE_DIR_KEY.equalsIgnoreCase(key)) { return properties.getProperty(Constants.CACHE_DIR_KEY, null); } String oldValue = (String) properties.remove(key.toLowerCase()); if (oldValue != null) { persistToDisk(); } return oldValue; } }
FileCacheStore implements CacheStore { @Override public String deleteFromCache(String key) throws CacheStoreException { Objects.requireNonNull(key, Utils.getMessage("IMG-0066")); if (Constants.CACHE_DIR_KEY.equalsIgnoreCase(key)) { return properties.getProperty(Constants.CACHE_DIR_KEY, null); } String oldValue = (String) properties.remove(key.toLowerCase()); if (oldValue != null) { persistToDisk(); } return oldValue; } FileCacheStore(); }
FileCacheStore implements CacheStore { @Override public String deleteFromCache(String key) throws CacheStoreException { Objects.requireNonNull(key, Utils.getMessage("IMG-0066")); if (Constants.CACHE_DIR_KEY.equalsIgnoreCase(key)) { return properties.getProperty(Constants.CACHE_DIR_KEY, null); } String oldValue = (String) properties.remove(key.toLowerCase()); if (oldValue != null) { persistToDisk(); } return oldValue; } FileCacheStore(); @Override String getCacheDir(); @Override String getValueFromCache(String key); @Override boolean hasMatchingKeyValue(String key, String value); @Override void addToCache(String key, String value); @Override String deleteFromCache(String key); @Override void clearCache(); @Override Map<String, String> getCacheItems(); }
FileCacheStore implements CacheStore { @Override public String deleteFromCache(String key) throws CacheStoreException { Objects.requireNonNull(key, Utils.getMessage("IMG-0066")); if (Constants.CACHE_DIR_KEY.equalsIgnoreCase(key)) { return properties.getProperty(Constants.CACHE_DIR_KEY, null); } String oldValue = (String) properties.remove(key.toLowerCase()); if (oldValue != null) { persistToDisk(); } return oldValue; } FileCacheStore(); @Override String getCacheDir(); @Override String getValueFromCache(String key); @Override boolean hasMatchingKeyValue(String key, String value); @Override void addToCache(String key, String value); @Override String deleteFromCache(String key); @Override void clearCache(); @Override Map<String, String> getCacheItems(); static final String CACHEDIR; }