Skyb.Extensions.Caching.MemCached 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Skyb.Extensions.Caching.MemCached --version 1.0.1                
NuGet\Install-Package Skyb.Extensions.Caching.MemCached -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Skyb.Extensions.Caching.MemCached" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Skyb.Extensions.Caching.MemCached --version 1.0.1                
#r "nuget: Skyb.Extensions.Caching.MemCached, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Skyb.Extensions.Caching.MemCached as a Cake Addin
#addin nuget:?package=Skyb.Extensions.Caching.MemCached&version=1.0.1

// Install Skyb.Extensions.Caching.MemCached as a Cake Tool
#tool nuget:?package=Skyb.Extensions.Caching.MemCached&version=1.0.1                

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

  1. Install the Skyb.Extensions.Caching.Memcached package from NuGet:

    dotnet add package Skyb.Extensions.Caching.Memcached
    

Usage

  1. 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), "cache.skybin.io:11211"); 
    
        // Other service configurations...
        //Store DateProtection Keys
        services.AddDataProtection().PersistKeysToMemCached(client, "DataProtectionKeys");
    }
    
  2. 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.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 0 11/28/2024
1.0.2 124 4/19/2024
1.0.1 104 4/19/2024
1.0.0 119 4/13/2024