Add cache invalidation methods and update project version to 1.1.
This commit is contained in:
Generated
+1
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
||||
Generated
+3
-1
@@ -3,7 +3,9 @@
|
||||
<component name="MaterialThemeProjectNewConfig">
|
||||
<option name="metadata">
|
||||
<MTProjectMetadataState>
|
||||
<option name="userId" value="69332f14:19db8254562:-7eee" />
|
||||
<option name="migrated" value="true" />
|
||||
<option name="pristineConfig" value="false" />
|
||||
<option name="userId" value="6d276d29:1992daa6e45:-7ffe" />
|
||||
</MTProjectMetadataState>
|
||||
</option>
|
||||
</component>
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'de.catmangames.jsonfetcher'
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
|
||||
@@ -38,6 +38,18 @@ public class JsonFetcher {
|
||||
return gson.fromJson(getRaw(path), type.getType());
|
||||
}
|
||||
|
||||
// Einzelnen Eintrag invalidieren
|
||||
public void invalidate(String path) {
|
||||
cacheData.remove(path);
|
||||
cacheTimestamps.remove(path);
|
||||
}
|
||||
|
||||
// Gesamten Cache leeren
|
||||
public void invalidateAll() {
|
||||
cacheData.clear();
|
||||
cacheTimestamps.clear();
|
||||
}
|
||||
|
||||
private String getRaw(String path) throws IOException {
|
||||
if (cacheTtlMs > 0 && cacheData.containsKey(path)) {
|
||||
long age = System.currentTimeMillis() - cacheTimestamps.get(path)[0];
|
||||
|
||||
Reference in New Issue
Block a user