Skyb.Framework.Extensions.Caching.MemCached 1.0.6
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.Memcachedpackage from NuGet:dotnet add package Skyb.Extensions.Caching.Memcached
Usage
Add Memcache caching to the services collection in your application's
Startup.csfile: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
IDistributedCacheinto 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
Showing the top 20 packages that depend on Skyb.Framework.Extensions.Caching.MemCached.
| Packages | Downloads |
|---|---|
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
0 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
1 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
3 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
4 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
5 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
6 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
12 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
13 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
15 |
|
Skyb.Nebula.Shared
SSC Nebula shared infrastructure — SSCStartup, SSCContext, shared persistence models, middleware, and services
|
47 |
.NET 10.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 10.0.10)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.11)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
- System.Security.Cryptography.Xml (>= 10.0.10)
.NET 8.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 10.0.10)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.11)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
- System.Security.Cryptography.Xml (>= 10.0.10)
.NET 9.0
- Enyim.Memcached2 (>= 0.6.8)
- Microsoft.AspNetCore.DataProtection (>= 10.0.10)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.11)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.10)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Options (>= 10.0.10)
- Newtonsoft.Json (>= 13.0.4)
- System.Security.Cryptography.Xml (>= 10.0.10)