Package de.xima.fc.api.cache
Class FileCache
- java.lang.Object
-
- de.xima.fc.api.cache.AGenericDataCache
-
- de.xima.fc.api.cache.FileCache
-
public class FileCache extends AGenericDataCache
-
-
Constructor Summary
Constructors Constructor Description FileCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
byte[]cacheFileData(UserContext uc, T entity)
static <T extends IFileEntity<?,?>>
byte[]cacheFileEntityData(UserContext uc, T fileEntity)
static <TFile extends IFileEntity<?,?>>
IFileAdaptergetCachedFile(UserContext uc, TFile file)
Gets a file adapter that accesses the file data via the file cache (if the file is cacheable).static <TFileMeta extends IFileMetaEntity<?,?>>
IFileAdaptergetCachedFile(UserContext uc, TFileMeta fileMeta)
Gets a file adapter that accesses the file data via the file cache (if the file is cacheable).static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
byte[]getCachedFileData(UserContext uc, T entity)
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.static <T extends IFileEntity<?,?>>
byte[]getCachedFileEntityData(UserContext uc, T fileEntity)
static byte[]
getCachedResourceData(String cacheKey)
static <FileEntity extends IFileEntity<?,?>,Data>
DatagetCachedTransformedFileEntityData(UserContext uc, FileEntity fileEntity, String transformId, IThrowingFunction<byte[],Data> transformer)
Gets the data of the given file entity, transformed via the given transformer.static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
byte[]getUncachedFileData(UserContext uc, T entity)
static <T extends IFileEntity<?,?>>
byte[]getUncachedFileEntityData(UserContext uc, T fileEntity)
static <E extends IFileDataEntity<?>,T extends IFileProviding<?,E>>
BinaryCacheModelreadCachedFileData(T entity)
static <T extends IFileEntity<?,?>>
BinaryCacheModelreadCachedFileEntityData(T fileEntity)
-
Methods inherited from class de.xima.fc.api.cache.AGenericDataCache
cacheData, readCachedData, readCachedData
-
-
-
-
Method Detail
-
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 transactionsfileEntity
- 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 transactionsfileMeta
- 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 transactionsfile
- 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)
-
-