Skyb.Extensions.Caching.MemCached
1.0.2
dotnet add package Skyb.Extensions.Caching.MemCached --version 1.0.2
NuGet\Install-Package Skyb.Extensions.Caching.MemCached -Version 1.0.2
<PackageReference Include="Skyb.Extensions.Caching.MemCached" Version="1.0.2" />
paket add Skyb.Extensions.Caching.MemCached --version 1.0.2
#r "nuget: Skyb.Extensions.Caching.MemCached, 1.0.2"
// Install Skyb.Extensions.Caching.MemCached as a Cake Addin #addin nuget:?package=Skyb.Extensions.Caching.MemCached&version=1.0.2 // Install Skyb.Extensions.Caching.MemCached as a Cake Tool #tool nuget:?package=Skyb.Extensions.Caching.MemCached&version=1.0.2
Skyb.Extensions.Caching.MemCached
Memcached Implementation for IDistributed Cache Memcached library for .NET Core 6, 7, 8
Memcache Integration for IDistributed Cache
Overview
This repository demonstrates how to integrate Memcache as an implementation of the IDistributedCache
interface in .NET applications. Memcache is a distributed caching system that is commonly used to improve the performance and scalability of web applications.
Prerequisites
- .NET Core SDK (version 5.0 or higher)
- Memcache server (Any)
Installation
Install the
Skyb.Extensions.Caching.Memcached
package from NuGet:dotnet add package Skyb.Extensions.Caching.Memcached
Usage
Add Memcache caching to the services collection in your application's
Startup.cs
file:using Skyb.Extensions.Caching.Memcached; public void ConfigureServices(IServiceCollection services) { // Add Memcache distributed cache var client = services.AddMemCache(TimeSpan.FromSeconds(30), "[ServerUrl]:[ServerPort]"); // Other service configurations... //Store DateProtection Keys services.AddDataProtection().PersistKeysToMemCached(client, "DataProtectionKeys"); }
Now you can inject
IDistributedCache
into your classes and use it for caching:using Microsoft.Extensions.Caching.Distributed; public class MyService { private readonly IDistributedCache _cache; public MyService(IDistributedCache cache) { _cache = cache; } public async Task<string> GetValueAsync(string key) { var cachedValue = await _cache.GetStringAsync(key); if (cachedValue == null) { // Value not found in cache, retrieve it from the data source cachedValue = "Value from data source"; // Cache the value for future requests await _cache.SetStringAsync(key, cachedValue, new DistributedCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) // Cache for 10 minutes }); } return cachedValue; } }
Contributing
Contributions are welcome! Please feel free to submit pull requests or open issues if you encounter any problems.
License
This project is licensed under the MIT License - see the LICENSE file for details.
💰 You can help me by Donating
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. 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 is compatible. 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. |
-
net5.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 8.0.4)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
-
net6.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 8.0.4)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
-
net7.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 8.0.4)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 8.0.4)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.2)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.