Class FileCache


public class FileCache extends AGenericDataCache
  • Constructor Details

    • FileCache

      public FileCache()
  • Method Details

    • getCachedFileData

      public static <E extends IFileDataEntity<?>, T extends IFileProviding<?,E>> byte[] getCachedFileData(UserContext uc, T entity)
    • getCachedFileData

      public static <TFileMeta extends IFileMetaEntity<?,?>> byte[] getCachedFileData(UserContext uc, TFileMeta fileEntity)
      Returns the cached file data if it exists within the file cache and is unchanged. Reads the file data from the database and creates a cache entry otherwise.
      Type Parameters:
      TFileMeta - type of the file entity.
      Parameters:
      uc - user context for database transactions
      fileEntity - to get the data for.
      Returns:
      the binary data of the file or null if it wasn't found.
      Since:
      8.2.0
    • getCachedFile

      public static <TFileMeta extends IFileMetaEntity<?,?>> IFileAdapter getCachedFile(UserContext uc, TFileMeta fileMeta)
      Gets a file adapter that accesses the file data via the file cache (if the file is cacheable).
      Type Parameters:
      TFileMeta - type of the file entity.
      Parameters:
      uc - user context for database transactions
      fileMeta - to get the file adapter for.
      Returns:
      the file adapter for the given file.
      Since:
      8.2.0
    • getCachedFileEntityData

      public static <T extends IFileEntity<?,?>> byte[] getCachedFileEntityData(UserContext uc, T fileEntity)
    • getCachedTransformedFileEntityData

      public static <FileEntity extends IFileEntity<?,?>, Data> Data getCachedTransformedFileEntityData(UserContext uc, FileEntity fileEntity, String transformId, IThrowingFunction<byte[],Data> transformer)
      Gets the data of the given file entity, transformed via the given transformer. Could be used, for example, to generate thumbnails of images.

      Returns the data from the cache if contained in the cache. Otherwise, reads the data from the database, applies the transformer and caches the transformed data.

      You also need to specify a transform ID. Different transformations of the same file entity should have different transform IDs.

      Type Parameters:
      FileEntity - Type of the file entity.
      Data - Type of the transformed data.
      Parameters:
      uc - User context for database transactions.
      fileEntity - File entity with the data.
      transformId - Identifier for the transformation.
      transformer - Function to transform the data. It is given the data of the file entity and should return the transformed data.
      Returns:
      Transformed data of the file entity.
      Since:
      8.3.0
    • getCachedFile

      public static <TFile extends IFileEntity<?,?>> IFileAdapter getCachedFile(UserContext uc, TFile file)
      Gets a file adapter that accesses the file data via the file cache (if the file is cacheable).
      Type Parameters:
      TFile - type of the file entity.
      Parameters:
      uc - user context for database transactions
      file - to get the file adapter for.
      Returns:
      the file adapter for the given file.
      Since:
      8.2.0
    • getUncachedFileEntityData

      public static <T extends IFileEntity<?,?>> byte[] getUncachedFileEntityData(UserContext uc, T fileEntity)
    • getUncachedFileData

      public static <E extends IFileDataEntity<?>, T extends IFileProviding<?,E>> byte[] getUncachedFileData(UserContext uc, T entity)
    • readCachedFileData

      public static <E extends IFileDataEntity<?>, T extends IFileProviding<?,E>> BinaryCacheModel readCachedFileData(T entity)
    • readCachedFileEntityData

      public static <T extends IFileEntity<?,?>> BinaryCacheModel readCachedFileEntityData(T fileEntity)
    • cacheFileEntityData

      public static <T extends IFileEntity<?,?>> byte[] cacheFileEntityData(UserContext uc, T fileEntity)
    • cacheFileData

      public static <E extends IFileDataEntity<?>, T extends IFileProviding<?,E>> byte[] cacheFileData(UserContext uc, T entity)
    • getCachedResourceData

      public static byte[] getCachedResourceData(String cacheKey)