FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

OnTopic-Library/OnTopic.Data.Caching/README.md at master · OnTopicCMS/OnTopic-Library · GitHub

Latest commit

 

History

History
32 lines (27 loc) · 1.84 KB

File metadata and controls

32 lines (27 loc) · 1.84 KB

OnTopic Cached Repository

The CachedTopicRepository decorates another ITopicRepository implementation with an in-memory cache. It is recommended that web applications decorate their ITopicRepository implementation.

Contents

Functionality

When topics are requested, they are pulled from the cache, if they exist; otherwise, they are pulled from the underlying ITopicRepository implementation, and then cached. Similarly, when topics are e.g. saved or moved, the updated versions are persisted to the underlying ITopicRepository, and then updated in the cache.

Installation

Installation can be performed by providing a <PackageReference /> to the OnTopic.Data.Caching NuGet package.

<Project Sdk="Microsoft.NET.Sdk.Web">
  …
  <ItemGroup>
    <PackageReference Include="OnTopic.Data.Caching" Version="5.0.0" />
  </ItemGroup>
</Project>

Usage

var sqlTopicRepository      = new SqlTopicRepository(connectionString);
var cachedTopicRepository   = new CachedTopicRepository(sqlTopicRepository);
var rootTopic               = cachedTopicRepository.Load();

Back | FazBrowse Home | New Git URL