@@ -73,6 +73,7 @@ private static void loadCacheFromDisk() {
73
73
Path earningsPath = cacheDirectory .resolve ("earnings_cache.json" );
74
74
Path metricsPath = cacheDirectory .resolve ("metrics_cache.json" );
75
75
Path incomePath = cacheDirectory .resolve ("income_cache.json" );
76
+ Path sentimentPath = cacheDirectory .resolve ("sentiment_cache.json" );
76
77
77
78
if (Files .exists (earningsPath )) {
78
79
JsonNode node = mapper .readTree (earningsPath .toFile ());
@@ -101,6 +102,16 @@ private static void loadCacheFromDisk() {
101
102
incomeCache .put (entry .getKey (), cacheEntry );
102
103
});
103
104
}
105
+
106
+ if (Files .exists (sentimentPath )) {
107
+ JsonNode node = mapper .readTree (sentimentPath .toFile ());
108
+ node .fields ().forEachRemaining (entry -> {
109
+ CacheEntry <List <NewsSentiment >> cacheEntry = mapper .convertValue (entry .getValue (),
110
+ mapper .getTypeFactory ().constructParametricType (CacheEntry .class ,
111
+ mapper .getTypeFactory ().constructCollectionType (List .class , NewsSentiment .class )));
112
+ sentimentCache .put (entry .getKey (), cacheEntry );
113
+ });
114
+ }
104
115
} catch (IOException e ) {
105
116
// Log error but continue - worst case we start with empty cache
106
117
System .err .println ("Failed to load cache from disk: " + e .getMessage ());
@@ -112,6 +123,7 @@ private static void saveCacheToDisk() {
112
123
mapper .writeValue (cacheDirectory .resolve ("earnings_cache.json" ).toFile (), earningsCache );
113
124
mapper .writeValue (cacheDirectory .resolve ("metrics_cache.json" ).toFile (), metricsCache );
114
125
mapper .writeValue (cacheDirectory .resolve ("income_cache.json" ).toFile (), incomeCache );
126
+ mapper .writeValue (cacheDirectory .resolve ("sentiment_cache.json" ).toFile (), sentimentCache );
115
127
} catch (IOException e ) {
116
128
System .err .println ("Failed to save cache to disk: " + e .getMessage ());
117
129
}
0 commit comments