Class DefaultLocalMediaFileCacheService
java.lang.Object
de.hybris.platform.media.storage.impl.DefaultLocalMediaFileCacheService
- All Implemented Interfaces:
LocalMediaFileCacheService
Default implementation of LocalMediaFileCache interface. Allows to cache locally any stream and returns
binary data as File or FileInputStream from local cache.
To configure folder to use local cache use following property key:
folder.folderQualifier.local.cache = true
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classNested classes/interfaces inherited from interface de.hybris.platform.media.storage.LocalMediaFileCacheService
LocalMediaFileCacheService.StreamGetter -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidinit()Recreates cache and adds lifecycle callback after bean constructionvoidremoveFromCache(MediaStorageConfigService.MediaFolderConfig config, String location) Removes given media from local cache.voidsetCacheController(CacheController cacheController) voidsetCacheRecreator(MediaCacheRecreator cacheRecreator) voidsetMainDataDir(File mainDataDir) voidsetMediaCacheRegion(MediaCacheRegion mediaCacheRegion) voidsetStorageConfigService(MediaStorageConfigService storageConfigService) voidsetStorageRegistry(MediaStorageRegistry storageRegistry) voidsetStorageStrategy(LocalFileMediaStorageStrategy storageStrategy) storeOrGetAsFile(MediaStorageConfigService.MediaFolderConfig config, String location, LocalMediaFileCacheService.StreamGetter streamGetter) Checks whether there is local cached version of media data and stores it if not, then returns it as regularFiletaken from cache.storeOrGetAsStream(MediaStorageConfigService.MediaFolderConfig config, String location, LocalMediaFileCacheService.StreamGetter streamGetter) Checks whether there is local cached version of media data and stores it if not, then returns it asFileInputStreambuild on top of cached file.
-
Field Details
-
CACHE_FILE_NAME_DELIM
- See Also:
-
CACHE_FILE_NO_RESTORABLE
- See Also:
-
PREVENT_LONGFILENAMES_LOCALCACHE
- See Also:
-
-
Constructor Details
-
DefaultLocalMediaFileCacheService
public DefaultLocalMediaFileCacheService()
-
-
Method Details
-
init
@PostConstruct public void init()Recreates cache and adds lifecycle callback after bean construction -
storeOrGetAsFile
public File storeOrGetAsFile(MediaStorageConfigService.MediaFolderConfig config, String location, LocalMediaFileCacheService.StreamGetter streamGetter) Description copied from interface:LocalMediaFileCacheServiceChecks whether there is local cached version of media data and stores it if not, then returns it as regularFiletaken from cache.- Specified by:
storeOrGetAsFilein interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the locationstreamGetter- the stream getter which returns proper data stream for particularMediaitem.- Returns:
- the
Fileobject
-
storeOrGetAsStream
public InputStream storeOrGetAsStream(MediaStorageConfigService.MediaFolderConfig config, String location, LocalMediaFileCacheService.StreamGetter streamGetter) Description copied from interface:LocalMediaFileCacheServiceChecks whether there is local cached version of media data and stores it if not, then returns it asFileInputStreambuild on top of cached file.- Specified by:
storeOrGetAsStreamin interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the locationstreamGetter- the stream getter which returns proper data stream for particularMediaitem.- Returns:
- the
FileInputStreamobject
-
removeFromCache
Description copied from interface:LocalMediaFileCacheServiceRemoves given media from local cache. This method is safe in terms of whenever some stream is already opened it will wait with removing cached file from disk until last client will close stream.- Specified by:
removeFromCachein interfaceLocalMediaFileCacheService- Parameters:
config- media folder config objectlocation- the location of cached file in real storage
-
setMainDataDir
-
setCacheController
-
setStorageRegistry
-
setStorageStrategy
-
setMediaCacheRegion
-
setStorageConfigService
-
setCacheRecreator
-