These samples depends on Microsoft.Extensions.Caching.Memory
library.
Caching - Absolute/Sliding expiration
This is the most basic caching you can use either by setting absolute or sliding expiration for your cache. Absolute expiration will remove your cache at a certain point in the future. Sliding expiration will remove your cache after period of inactivity.
Add file dependency to your caching so when the file changes, your cache expires. Make sure to set
cache-file.txt
to copy over to bin.Caching 3 - Cache removal event
Register callback when a cached value is removed.
Caching 4 - CancellationChangeToken dependency
Bind several cache entries to a single dependency that you can reset manually.
This sample uses the
Microsoft.Extensions.Caching.StackExchangeRedis
to store caching value in Redis.
dotnet8