Skip to content

lukehook/UmbracoSparkHybridCache

Repository files navigation

UmbracoSparkHybridCache

Overview

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.

Project Structure

.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/

Getting Started

Prerequisites

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

Setup

  1. Clone the repository:

    git clone https://github.com/yourusername/UmbracoSparkHybridCache.git
    cd UmbracoSparkHybridCache
  2. Restore the dependencies:

    dotnet restore
  3. Update the Redis connection string in appsettings.json for both SparkFusionCache and SparkHybridCache projects.

Running the Applications

SparkFusionCache

  1. Navigate to the SparkFusionCache directory:

    cd SparkFusionCache
  2. Run the application:

    dotnet run
  3. Open your browser and navigate to http://localhost:7109.

or

  1. Open the SparkFusionCache.http files and simulate the requests

SparkHybridCache

  1. Navigate to the SparkHybridCache directory:

    cd SparkHybridCache
  2. Run the application:

    dotnet run
  3. Open your browser and navigate to http://localhost:7010.

or

  1. Open the SparkHybridCache.http files and simulate the requests

Usage

  • 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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published