UmbracoSparkHybridCache is a project that demonstrates the use of hybrid caching with distributed and in-memory caching for a Pokémon API. The project consists of three main components:
- SparkFusionCache: A web application that uses FusionCache for caching Pokémon data.
- SparkHybridCache: A web application that uses HybridCache for caching Pokémon data.
- SparkShared: A shared library containing common code used by both web applications.
Note
This demo utilises the free and open source PokeAPI - this is a RESTful service that responds with Pokemon data that is used for the purpose of demonstrating the HybridCache functionality. Please use this service responsibly.
.gitattributes
.gitignore
UmbracoSparkHybridCache.sln
.github/
workflows/
.vs/
VSWorkspaceState.json
ProjectEvaluation/
umbracosparkhybridcache.metadata.v9.bin
umbracosparkhybridcache.projects.v9.bin
umbracosparkhybridcache.strings.v9.bin
UmbracoSparkHybridCache/
config/
copilot-chat/
CopilotIndices/
DesignTimeBuild/
FileContentIndex/
RestEditor/
v17/
Properties/
launchSettings.json
SparkFusionCache/
appsettings.Development.json
appsettings.json
http-client.env.json
Program.cs
SparkFusionCache.csproj
SparkFusionCache.csproj.user
SparkFusionCache.http
bin/
Debug/
obj/
project.assets.json
project.nuget.cache
Properties/
launchSettings.json
wwwroot/
css/
styles.css
fonts/
Pokemon Hollow.ttf
Pokemon Solid.ttf
index.html
js/
script.js
SparkHybridCache/
appsettings.Development.json
appsettings.json
http-client.env.json
index.html
Program.cs
SparkHybridCache.csproj
SparkHybridCache.csproj.user
SparkHybridCache.http
bin/
obj/
Properties/
launchSettings.json
wwwroot/
css/
styles.css
fonts/
Pokemon Hollow.ttf
Pokemon Solid.ttf
index.html
js/
script.js
SparkShared/
PokemonResponse.cs
PokemonService.cs
SparkShared.csproj
bin/
obj/
Note
The projects in this repo are using .NET 9 and will require the .NET 9 runtime to function. However HybridCache and FusionCache are compatible with verions of .NET as far back as .NET Framework 4.7.2
Note
This example uses Redis as an IDistributedCache. You can provide your own connectionString to a Redis resource or swap out the IDistributedCache for a different implementation such as SQLServer
-
Clone the repository:
git clone https://github.com/yourusername/UmbracoSparkHybridCache.git cd UmbracoSparkHybridCache
-
Restore the dependencies:
dotnet restore
-
Update the Redis connection string in
appsettings.json
for bothSparkFusionCache
andSparkHybridCache
projects.
-
Navigate to the
SparkFusionCache
directory:cd SparkFusionCache
-
Run the application:
dotnet run
-
Open your browser and navigate to
http://localhost:7109
.
or
- Open the
SparkFusionCache.http
files and simulate the requests
-
Navigate to the
SparkHybridCache
directory:cd SparkHybridCache
-
Run the application:
dotnet run
-
Open your browser and navigate to
http://localhost:7010
.
or
- Open the
SparkHybridCache.http
files and simulate the requests
- Enter a Pokémon name in the input field and click "Submit" to fetch Pokémon data.
- Use the "Types" button to filter Pokémon by type.
- Use the "Clear Tags" button to clear cached data by tag.
This project is licensed under the MIT License - see the LICENSE file for details.