@@ -25,9 +25,9 @@ public class PhysicalFileSystemCache : IImageCache
2525 private readonly string cacheRootPath ;
2626
2727 /// <summary>
28- /// The length of the filename to use (minus the extension) when storing images in the image cache .
28+ /// The depth of the nested cache folders structure to store the images .
2929 /// </summary>
30- private readonly int cachedNameLength ;
30+ private readonly int cacheFolderDepth ;
3131
3232 /// <summary>
3333 /// The file provider abstraction.
@@ -80,7 +80,7 @@ public PhysicalFileSystemCache(
8080
8181 this . fileProvider = new PhysicalFileProvider ( this . cacheRootPath ) ;
8282 this . options = options . Value ;
83- this . cachedNameLength = ( int ) this . options . CachedNameLength ;
83+ this . cacheFolderDepth = ( int ) this . options . CacheHashLength ;
8484 this . formatUtilities = formatUtilities ;
8585 }
8686
@@ -105,7 +105,7 @@ internal static string GetCacheRoot(PhysicalFileSystemCacheOptions cacheOptions,
105105 /// <inheritdoc/>
106106 public Task < IImageCacheResolver > GetAsync ( string key )
107107 {
108- string path = ToFilePath ( key , this . cachedNameLength ) ;
108+ string path = ToFilePath ( key , this . cacheFolderDepth ) ;
109109
110110 IFileInfo metaFileInfo = this . fileProvider . GetFileInfo ( this . ToMetaDataFilePath ( path ) ) ;
111111 if ( ! metaFileInfo . Exists )
@@ -119,7 +119,7 @@ public Task<IImageCacheResolver> GetAsync(string key)
119119 /// <inheritdoc/>
120120 public async Task SetAsync ( string key , Stream stream , ImageCacheMetadata metadata )
121121 {
122- string path = Path . Combine ( this . cacheRootPath , ToFilePath ( key , this . cachedNameLength ) ) ;
122+ string path = Path . Combine ( this . cacheRootPath , ToFilePath ( key , this . cacheFolderDepth ) ) ;
123123 string imagePath = this . ToImageFilePath ( path , metadata ) ;
124124 string metaPath = this . ToMetaDataFilePath ( path ) ;
125125 string directory = Path . GetDirectoryName ( path ) ;
@@ -162,13 +162,13 @@ private string ToImageFilePath(string path, in ImageCacheMetadata metaData)
162162 /// Converts the key into a nested file path.
163163 /// </summary>
164164 /// <param name="key">The cache key.</param>
165- /// <param name="cachedNameLength ">The length of the cached file name minus the extension .</param>
165+ /// <param name="cacheFolderDepth ">The depth of the nested cache folders structure to store the images .</param>
166166 /// <returns>The <see cref="string"/>.</returns>
167167 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
168- internal static unsafe string ToFilePath ( string key , int cachedNameLength )
168+ internal static unsafe string ToFilePath ( string key , int cacheFolderDepth )
169169 {
170170 // Each key substring char + separator + key
171- int length = ( cachedNameLength * 2 ) + key . Length ;
171+ int length = ( cacheFolderDepth * 2 ) + key . Length ;
172172 fixed ( char * keyPtr = key )
173173 {
174174 return string . Create ( length , ( Ptr : ( IntPtr ) keyPtr , key . Length ) , ( chars , args ) =>
@@ -179,7 +179,7 @@ internal static unsafe string ToFilePath(string key, int cachedNameLength)
179179 ref char charRef = ref MemoryMarshal . GetReference ( chars ) ;
180180
181181 int index = 0 ;
182- for ( int i = 0 ; i < cachedNameLength ; i ++ )
182+ for ( int i = 0 ; i < cacheFolderDepth ; i ++ )
183183 {
184184 Unsafe . Add ( ref charRef , index ++ ) = Unsafe. Add ( ref keyRef , i ) ;
185185 Unsafe . Add ( ref charRef , index ++ ) = separator;
0 commit comments