Package growthbook.sdk.java.sandbox
Class FileCachingManagerImpl
java.lang.Object
growthbook.sdk.java.sandbox.FileCachingManagerImpl
- All Implemented Interfaces:
GbCacheManager
Class responsible for caching data to a file
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClears all cache files in the directorygetLastUpdatedMillis(String fileName) Returns when the cached value was last updated, in epoch milliseconds.Method that fetches data from cache by file namevoidsaveContent(String fileName, String content) Method that saves feature JSON as String to a cache file
-
Constructor Details
-
FileCachingManagerImpl
-
-
Method Details
-
saveContent
Method that saves feature JSON as String to a cache file- Specified by:
saveContentin interfaceGbCacheManager- Parameters:
fileName- The name of file in the cache directorycontent- Feature JSON as String type
-
loadCache
Method that fetches data from cache by file name- Specified by:
loadCachein interfaceGbCacheManager- Parameters:
fileName- The name of the file in the cache directory.- Returns:
- The cached data as a String.
-
getLastUpdatedMillis
Description copied from interface:GbCacheManagerReturns when the cached value was last updated, in epoch milliseconds.The optional background feature refresh interval uses this timestamp to decide whether cached features are fresh enough to skip a network refresh. Custom cache implementations may return
nullwhen timestamp tracking is unsupported or when the key does not exist; in that case the SDK treats cache freshness as unknown and performs the network refresh. Implementations should throwFeatureCacheExceptionfor real cache access failures.- Specified by:
getLastUpdatedMillisin interfaceGbCacheManager
-
clearCache
public void clearCache()Clears all cache files in the directory- Specified by:
clearCachein interfaceGbCacheManager
-