Skip to content

Commit bc1daa8

Browse files
committed
Add an option to enable setting a different CacheRoot
1 parent 2c5961e commit bc1daa8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/ImageSharp.Web/Caching/PhysicalFileSystemCache.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ public PhysicalFileSystemCache(
7272

7373
// Allow configuration of the cache without having to register everything.
7474
this.cacheOptions = cacheOptions != null ? cacheOptions.Value : new PhysicalFileSystemCacheOptions();
75-
this.cacheRootPath = Path.Combine(environment.WebRootPath, this.cacheOptions.CacheFolder);
75+
var cacheRoot = string.IsNullOrEmpty(this.cacheOptions.CacheRoot)
76+
? environment.WebRootPath
77+
: this.cacheOptions.CacheRoot;
78+
this.cacheRootPath = Path.Combine(cacheRoot, this.cacheOptions.CacheFolder);
7679
if (!Directory.Exists(this.cacheRootPath))
7780
{
7881
Directory.CreateDirectory(this.cacheRootPath);

src/ImageSharp.Web/Caching/PhysicalFileSystemCacheOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ public class PhysicalFileSystemCacheOptions
1212
/// Gets or sets the cache folder name.
1313
/// </summary>
1414
public string CacheFolder { get; set; } = "is-cache";
15+
16+
/// <summary>
17+
/// Gets or sets the cache root folder.
18+
/// </summary>
19+
public string CacheRoot { get; set; }
1520
}
1621
}

0 commit comments

Comments
 (0)