Class FileCachingManagerImpl

java.lang.Object
growthbook.sdk.java.sandbox.FileCachingManagerImpl
All Implemented Interfaces:
GbCacheManager

public class FileCachingManagerImpl extends Object implements GbCacheManager
Class responsible for caching data to a file
  • Constructor Details

    • FileCachingManagerImpl

      public FileCachingManagerImpl(String filePath)
  • Method Details

    • saveContent

      public void saveContent(String fileName, String content)
      Method that saves feature JSON as String to a cache file
      Specified by:
      saveContent in interface GbCacheManager
      Parameters:
      fileName - The name of file in the cache directory
      content - Feature JSON as String type
    • loadCache

      public String loadCache(String fileName)
      Method that fetches data from cache by file name
      Specified by:
      loadCache in interface GbCacheManager
      Parameters:
      fileName - The name of the file in the cache directory.
      Returns:
      The cached data as a String.
    • getLastUpdatedMillis

      public Long getLastUpdatedMillis(String fileName)
      Description copied from interface: GbCacheManager
      Returns 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 null when 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 throw FeatureCacheException for real cache access failures.

      Specified by:
      getLastUpdatedMillis in interface GbCacheManager
    • clearCache

      public void clearCache()
      Clears all cache files in the directory
      Specified by:
      clearCache in interface GbCacheManager