We have implemented a custom ImageProvider which get an image from a database. Hereafter we have added the blob storage cache.
builder.Services.AddImageSharp()
.ClearProviders()
.SetCache<AzureBlobStorageCache>()
.Configure<AzureBlobStorageCacheOptions>(options =>
{
options.ConnectionString = builder.Configuration["xx"];
options.ContainerName = "cachexx";
// Optionally create the cache container on startup if not already created.
AzureBlobStorageCache.CreateIfNotExists(options, PublicAccessType.None);
})
.Configure<AzureBlobStorageImageProviderOptions>(options =>
{
// The "BlobContainers" collection allows registration of multiple containers.
options.BlobContainers.Add(new AzureBlobContainerClientOptions
{
ConnectionString = builder.Configuration["xx"],
ContainerName = "xx",
});
})
.AddProvider<AzureBlobStorageImageProvider>()
.AddProvider<DatabaseImageProvider>() ;
We can see the image in the blob storage so it is read from the database, added to the cache and served to the browser. However after the image is added to the cache the ImageProvider GetAsync method is still called every time the same image is requested. I would assume that the ImageProvider would first be called again when the cache is invalid. Is this something I have misunderstood or might we be missing something in regards to the cache.