-
- All Implemented Interfaces:
-
com.facebook.cache.disk.DiskStorage
public class DefaultDiskStorage implements DiskStorage
The default disk storage implementation. Subsumes both 'simple' and 'sharded' implementations via a new SubdirectorySupplier.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceDefaultDiskStorage.FileTypeCategories for the different internal files a ShardedDiskStorage maintains. CONTENT: the filethat has the content TEMP: temporal files, used to write the content until they are switched toCONTENT files
-
Constructor Summary
Constructors Constructor Description DefaultDiskStorage(File rootDirectory, int version, CacheErrorLogger cacheErrorLogger)Instantiates a ShardedDiskStorage that will use the directory to save a map between keys andfiles.
-
Method Summary
Modifier and Type Method Description booleanisEnabled()is this storage enabled? booleanisExternal()is this storage external? StringgetStorageName()Get the storage's name, which should be unique voidpurgeUnexpectedResources()DiskStorage.Inserterinsert(String resourceId, Object debugInfo)Creates a temporary resource for writing content. BinaryResourcegetResource(String resourceId, Object debugInfo)Get the resource with the specified name booleancontains(String resourceId, Object debugInfo)Does a resource with this name exist? booleantouch(String resourceId, Object debugInfo)Does a resource with this name exist? longremove(DiskStorage.Entry entry)Remove the resource represented by the entry longremove(String resourceId)Remove the resource with specified id voidclearAll()Clear all contents of the storage DiskStorage.DiskDumpInfogetDumpInfo()List<DiskStorage.Entry>getEntries()Get all entries currently in the storage -
-
Constructor Detail
-
DefaultDiskStorage
DefaultDiskStorage(File rootDirectory, int version, CacheErrorLogger cacheErrorLogger)
Instantiates a ShardedDiskStorage that will use the directory to save a map between keys andfiles.- Parameters:
rootDirectory- root directory to create all content underversion- version of the format used in the files.cacheErrorLogger- logger for various events
-
-
Method Detail
-
isEnabled
boolean isEnabled()
is this storage enabled?
-
isExternal
boolean isExternal()
is this storage external?
-
getStorageName
String getStorageName()
Get the storage's name, which should be unique
-
purgeUnexpectedResources
void purgeUnexpectedResources()
-
insert
DiskStorage.Inserter insert(String resourceId, Object debugInfo)
Creates a temporary resource for writing content. Split from commit() in order to allowconcurrent writing of cache entries. This entry will not be available to cache clients untilcommit() is called passing in the resource returned from this method.
- Parameters:
resourceId- id of the resourcedebugInfo- helper object for debugging
-
getResource
@Nullable() BinaryResource getResource(String resourceId, Object debugInfo)
Get the resource with the specified name
- Parameters:
resourceId- id of the resourcedebugInfo- helper object for debugging
-
contains
boolean contains(String resourceId, Object debugInfo)
Does a resource with this name exist?
- Parameters:
resourceId- id of the resourcedebugInfo- helper object for debugging
-
touch
boolean touch(String resourceId, Object debugInfo)
Does a resource with this name exist? If so, update the last-accessed time for the resource
- Parameters:
resourceId- id of the resourcedebugInfo- helper object for debugging
-
remove
long remove(DiskStorage.Entry entry)
Remove the resource represented by the entry
- Parameters:
entry- entry of the resource to delete
-
clearAll
void clearAll()
Clear all contents of the storage
-
getDumpInfo
DiskStorage.DiskDumpInfo getDumpInfo()
-
getEntries
List<DiskStorage.Entry> getEntries()
Get all entries currently in the storage
-
-
-
-