EnyimMemcachedCore 2.6.4

.NET 6.0 .NET Standard 2.0
dotnet add package EnyimMemcachedCore --version 2.6.4
NuGet\Install-Package EnyimMemcachedCore -Version 2.6.4
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="EnyimMemcachedCore" Version="2.6.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EnyimMemcachedCore --version 2.6.4
#r "nuget: EnyimMemcachedCore, 2.6.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install EnyimMemcachedCore as a Cake Addin
#addin nuget:?package=EnyimMemcachedCore&version=2.6.4

// Install EnyimMemcachedCore as a Cake Tool
#tool nuget:?package=EnyimMemcachedCore&version=2.6.4

Enyim Memcached Client

This is a memcached client library for .NET migrated from EnyimMemcached.

Configure

The appsettings.json Without Authentication

{
  "enyimMemcached": {
    "Servers": [
      {
        "Address": "memcached",
        "Port": 11211
      }
    ],
    "Transcoder": "MessagePackTranscoder"
  }
}
The appsettings.json With Authentication
{
  "enyimMemcached": {
    "Servers": [
      {
        "Address": "memcached",
        "Port": 11211
      }
    ],
    "Authentication": {
      "Type": "Enyim.Caching.Memcached.PlainTextAuthenticator",
      "Parameters": {
        "zone": "",
        "userName": "username",
        "password": "password"
      }
    }
  }
}

Startup.cs

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddEnyimMemcached();
        // services.AddEnyimMemcached("enyimMemcached");
        // services.AddEnyimMemcached(Configuration);
        // services.AddEnyimMemcached(Configuration, "enyimMemcached");
        // services.AddEnyimMemcached(Configuration.GetSection("enyimMemcached"));
        // services.AddEnyimMemcached(options => options.AddServer("memcached", 11211));
    }
    
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    { 
        app.UseEnyimMemcached();
    }
}

Example usage

Use IMemcachedClient interface

public class HomeController : Controller
{
    private readonly IMemcachedClient _memcachedClient;
    private readonly IBlogPostService _blogPostService;

    public HomeController(IMemcachedClient memcachedClient, IBlogPostService blogPostService)
    {
        _memcachedClient = memcachedClient;
        _blogPostService = blogPostService;
    }

    public async Task<IActionResult> Index()
    {
        var cacheKey = "blogposts-recent";
        var cacheSeconds = 600;

        var posts = await _memcachedClient.GetValueOrCreateAsync(
            cacheKey,
            cacheSeconds,
            async () => await _blogPostService.GetRecent(10));

        return Ok(posts);
    }
}

Use IDistributedCache interface

public class CreativeService
{
    private ICreativeRepository _creativeRepository;
    private IDistributedCache _cache;

    public CreativeService(
        ICreativeRepository creativeRepository,
        IDistributedCache cache)
    {
        _creativeRepository = creativeRepository;
        _cache = cache;
    }

    public async Task<IList<CreativeDTO>> GetCreatives(string unitName)
    {
        var cacheKey = $"creatives_{unitName}";
        IList<CreativeDTO> creatives = null;

        var creativesJson = await _cache.GetStringAsync(cacheKey);
        if (creativesJson == null)
        {
            creatives = await _creativeRepository.GetCreatives(unitName)
                    .ProjectTo<CreativeDTO>().ToListAsync();

            var json = string.Empty;
            if (creatives != null && creatives.Count() > 0)
            {
                json = JsonConvert.SerializeObject(creatives);
            }
            await _cache.SetStringAsync(
                cacheKey, 
                json, 
                new DistributedCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(5)));
        }
        else
        {
            creatives = JsonConvert.DeserializeObject<List<CreativeDTO>>(creativesJson);
        }

        return creatives;
    }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (39)

Showing the top 5 NuGet packages that depend on EnyimMemcachedCore:

Package Downloads
EasyCaching.Memcached

A simple distributed caching provider based on EnyimMemcachedCore.

Senparc.CO2NET.Cache.Memcached The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

微信公众账号 - Memcached 模块 Senparc.CO2NET SDK 开源项目: https://github.com/JeffreySu/WeiXinMPSDK

RsCode.AspNetCore

https://rscode.cn

EDQ.WMS.Infrastructrue

Package Description

MT.DotNetCore

MT DotNetCore Common Libs.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on EnyimMemcachedCore:

Repository Stars
dotnetcore/EasyCaching
:boom: EasyCaching is an open source caching library that contains basic usages and some advanced usages of caching which can help us to handle caching more easier!
Cysharp/MasterMemory
Embedded Typed Readonly In-Memory Document Database for .NET Core and Unity.
grissomlau/jimu
.netcore micro service framework
Senparc/Senparc.CO2NET
支持 .NET Framework & .NET Core 的公共基础扩展库
catcherwong/Demos
:100:Some demos for learning
Version Downloads Last updated
2.6.4 419 1/29/2023
2.6.3 69 1/29/2023
2.6.2 68 1/29/2023
2.6.1 66 1/29/2023
2.6.0 2,358 1/18/2023
2.5.7 3,458 1/1/2023
2.5.6 25,578 11/24/2022
2.5.5 8,636 11/4/2022
2.5.4 130,629 7/3/2022
2.5.3 733,583 1/27/2021
2.5.2 39,693 1/3/2021
2.5.2-preview1 558 12/4/2020
2.5.1 36,612 12/2/2020
2.5.0 487 12/2/2020
2.5.0-preview3 278 11/30/2020
2.5.0-preview2 293 11/30/2020
2.5.0-preview1 267 11/14/2020
2.4.5 180,789 11/17/2020
2.4.4 113,840 8/25/2020
2.4.3 179,547 3/25/2020
2.4.2 28,746 2/25/2020
2.4.1 174,292 10/16/2019
2.4.0 122,282 9/15/2019
2.3.0 34,679 7/10/2019
2.2.4 67,863 6/15/2019
2.2.3 12,251 5/25/2019
2.2.2 8,448 5/17/2019
2.2.0 35,140 5/16/2019
2.1.14 15,980 5/3/2019
2.1.13 7,429 4/21/2019
2.1.12 37,933 12/31/2018
2.1.11 1,033 12/30/2018
2.1.10 179,749 9/22/2018
2.1.9 23,620 9/16/2018
2.1.8 58,217 6/18/2018
2.1.7 2,809 6/12/2018
2.1.5 73,953 5/30/2018
2.1.3 1,226 5/29/2018
2.1.2 3,378 5/24/2018
2.1.1 11,141 5/23/2018
2.1.0.7 38,891 4/2/2018
2.1.0.6 1,596 3/26/2018
2.1.0.5 4,186 3/8/2018
2.1.0.4 1,542 3/5/2018
2.1.0.3 1,180 3/5/2018
2.1.0.2 27,674 1/19/2018
2.1.0.1 8,124 1/3/2018
2.1.0 62,418 12/15/2017
2.0.4 1,130 12/12/2017
2.0.2 22,268 9/7/2017
2.0.1 15,835 8/19/2017
2.0.0 4,620 8/15/2017
2.0.0-beta1 1,960 7/12/2017
1.1.1.12 10,750 7/8/2017
1.1.1.11 1,133 7/8/2017
1.1.1.10 7,211 5/20/2017
1.1.1.9 1,162 5/20/2017
1.1.1.8 2,758 4/20/2017
1.1.1.7 5,768 3/18/2017
1.1.1.6 9,483 3/16/2017
1.1.1.5 1,704 3/7/2017
1.1.1.4 1,322 3/7/2017
1.1.1.3 12,767 1/2/2017
1.1.1.2 1,360 12/24/2016
1.1.1.1 1,978 12/20/2016
1.1.1 1,527 12/10/2016
1.1.0.2 1,612 12/10/2016
1.1.0.1 1,419 12/8/2016
1.1.0 1,412 12/5/2016
1.0.0.8 5,932 11/11/2016
1.0.0.7-preview1 1,144 10/26/2016
1.0.0.6 4,612 10/20/2016
1.0.0.5 1,241 10/19/2016
1.0.0.4 1,294 10/18/2016
1.0.0.3 1,286 10/13/2016
1.0.0.2 1,319 9/27/2016
1.0.0.1 1,355 9/26/2016
1.0.0 1,640 3/25/2016