GroupDocs.Viewer.UI.Api.InMemory.Cache
8.1.1
Prefix Reserved
dotnet add package GroupDocs.Viewer.UI.Api.InMemory.Cache --version 8.1.1
NuGet\Install-Package GroupDocs.Viewer.UI.Api.InMemory.Cache -Version 8.1.1
<PackageReference Include="GroupDocs.Viewer.UI.Api.InMemory.Cache" Version="8.1.1" />
<PackageVersion Include="GroupDocs.Viewer.UI.Api.InMemory.Cache" Version="8.1.1" />
<PackageReference Include="GroupDocs.Viewer.UI.Api.InMemory.Cache" />
paket add GroupDocs.Viewer.UI.Api.InMemory.Cache --version 8.1.1
#r "nuget: GroupDocs.Viewer.UI.Api.InMemory.Cache, 8.1.1"
#:package GroupDocs.Viewer.UI.Api.InMemory.Cache@8.1.1
#addin nuget:?package=GroupDocs.Viewer.UI.Api.InMemory.Cache&version=8.1.1
#tool nuget:?package=GroupDocs.Viewer.UI.Api.InMemory.Cache&version=8.1.1
GroupDocs.Viewer.UI.Api.InMemory.Cache
GroupDocs.Viewer.UI.Api.InMemory.Cache
is an in-memory caching implementation that can be used with GroupDocs.Viewer.UI.Api
. It provides fast, in-memory caching for document rendering results in your GroupDocs.Viewer.UI
application.
Installation
To use InMemory Cache in your ASP.NET Core project:
- Add the required package to your project:
dotnet add package GroupDocs.Viewer.UI.Api.InMemory.Cache
- Configure InMemory Cache in your
Startup
class:
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddGroupDocsViewerUI();
builder.Services
.AddControllers()
.AddGroupDocsViewerSelfHostApi()
.AddLocalStorage("./Files")
.AddInMemoryCache(config =>
{
config.SetCacheEntryExpirationTimeoutMinutes(60); // Cache entries expire after 60 minutes
config.SetGroupCacheEntriesByFile(true); // Group cache entries by file
});
var app = builder.Build();
app
.UseRouting()
.UseEndpoints(endpoints =>
{
endpoints.MapGroupDocsViewerUI(options =>
{
options.UIPath = "/viewer";
options.ApiEndpoint = "/viewer-api";
});
endpoints.MapGroupDocsViewerApi(options =>
{
options.ApiPath = "/viewer-api";
});
});
await app.RunAsync();
Configuration Options
The InMemory Cache implementation supports the following configuration options:
CacheEntryExpirationTimeoutMinutes
(Optional): The expiration timeout of each cache entry in minutes. Default is 0, which means cache entries never expire.GroupCacheEntriesByFile
(Optional): When enabled, eviction of any cache entry leads to eviction of all cache entries for that file. This setting only takes effect whenCacheEntryExpirationTimeoutMinutes
is greater than zero.
You can also configure these settings through appsettings.json
:
{
"GroupDocsViewerUIApiInMemoryCache": {
"CacheEntryExpirationTimeoutMinutes": 60,
"GroupCacheEntriesByFile": true
}
}
Technical Implementation
The InMemory Cache implementation uses ASP.NET Core's built-in IMemoryCache
for storing cached data. Here's how it works:
Cache Key Structure
- Each cache entry is identified by a composite key:
{filePath}_{cacheKey}
- The
filePath
represents the document being cached - The
cacheKey
represents the specific cached item (e.g., page thumbnail, page content)
Cache Entry Management
- Cache entries are stored in the application's process memory
- Uses
MemoryCacheEntryOptions
for controlling entry behavior - Supports both synchronous and asynchronous operations through
IFileCache
interface
Expiration Mechanism
When CacheEntryExpirationTimeoutMinutes
is set:
- A
CancellationTokenSource
is created for each cache entry - The token source is configured to cancel after the specified timeout
- Cache entries are linked to their token source through
CancellationChangeToken
- When the token is cancelled, the cache entry is automatically evicted
File-based Grouping
When GroupCacheEntriesByFile
is enabled:
- A single
CancellationTokenSource
is shared among all cache entries for a file - The token source key is
{filePath}__CTS
- When any cache entry expires, all entries for that file are evicted together
- This ensures consistency when a file's cache entries need to be invalidated
Memory Management
- Uses ASP.NET Core's built-in memory management
- Automatically handles memory pressure through the framework's eviction policies
- No explicit memory limits are set, relying on the system's available memory
- Cache entries are not persisted between application restarts
Performance Considerations
When using InMemory Cache:
- Cache size is limited by available system memory
- Cache is cleared when the application restarts
- Best suited for:
- Small to medium-sized document sets
- Applications with moderate concurrent users
- Development and testing environments
- Not recommended for:
- Large document sets
- High-traffic production environments
- Distributed applications
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- GroupDocs.Viewer.UI.Core (>= 8.1.1)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- System.Formats.Asn1 (>= 8.0.2)
- System.Text.Json (>= 8.0.6)
-
net8.0
- GroupDocs.Viewer.UI.Core (>= 8.1.1)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- System.Formats.Asn1 (>= 8.0.2)
- System.Text.Json (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.1.1 | 185 | 9/21/2025 |
8.0.7 | 213 | 5/23/2025 |
8.0.6 | 158 | 5/5/2025 |
8.0.5 | 177 | 4/23/2025 |
8.0.4 | 175 | 4/22/2025 |
8.0.3 | 142 | 4/4/2025 |
8.0.2 | 121 | 2/6/2025 |
8.0.1 | 140 | 12/20/2024 |
8.0.0 | 124 | 12/16/2024 |
6.0.5 | 114 | 12/2/2024 |
6.0.4 | 130 | 9/30/2024 |
6.0.3 | 1,086 | 6/11/2024 |
6.0.2 | 2,197 | 6/29/2023 |
6.0.1 | 198 | 6/29/2023 |
6.0.0 | 3,954 | 7/23/2022 |
3.1.1 | 2,189 | 11/18/2021 |
3.1.0 | 381 | 9/21/2021 |