EnyimMemcachedCore 3.3.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package EnyimMemcachedCore --version 3.3.1                
NuGet\Install-Package EnyimMemcachedCore -Version 3.3.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="EnyimMemcachedCore" Version="3.3.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EnyimMemcachedCore --version 3.3.1                
#r "nuget: EnyimMemcachedCore, 3.3.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 EnyimMemcachedCore as a Cake Addin
#addin nuget:?package=EnyimMemcachedCore&version=3.3.1

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

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 Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible. 
.NET Framework net48 is compatible.  net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (45)

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

WeChat Public Account - Memcached Module Senparc.CO2NET SDK Open Source Project: https://github.com/JeffreySu/WeiXinMPSDK

EDQ.WMS.Infrastructrue

Package Description

Zicard.API.Common

Bases microservices da Zicard API

MT.DotNetCore

MT DotNetCore Common Libs.

GitHub repositories (6)

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
Source Generator based Embedded Typed Readonly In-Memory Document Database for .NET and Unity.
grissomlau/jimu
.netcore micro service framework
Senparc/Senparc.CO2NET
Base Common Library, support for.NET Framework &.NET Core
catcherwong/Demos
:100:Some demos for learning
Version Downloads Last updated
3.3.2 179 12/19/2024
3.3.1 1,285 12/9/2024
3.3.0 5,162 11/23/2024
3.2.4 34,933 10/27/2024
3.2.3 91,328 9/2/2024
3.2.2 65,124 7/31/2024
3.2.1 299,542 4/3/2024
3.2.0 119,595 2/22/2024
3.1.0 616 2/21/2024
3.0.1 41,635 2/6/2024
3.0.0 18,798 1/31/2024
2.7.1 31,462 2/6/2024
2.7.0 160,339 12/2/2023
2.6.6 517,886 5/2/2023
2.6.5 3,521 4/28/2023
2.6.4 246,964 1/29/2023
2.6.3 1,410 1/29/2023
2.6.2 1,067 1/29/2023
2.6.1 1,142 1/29/2023
2.6.0 73,571 1/18/2023
2.5.7 87,098 1/1/2023
2.5.6 294,518 11/24/2022
2.5.5 46,547 11/4/2022
2.5.4 373,705 7/3/2022
2.5.3 1,303,756 1/27/2021
2.5.2 79,376 1/3/2021
2.5.2-preview1 1,468 12/4/2020
2.5.1 45,153 12/2/2020
2.5.0 2,155 12/2/2020
2.5.0-preview3 1,190 11/30/2020
2.5.0-preview2 1,152 11/30/2020
2.5.0-preview1 1,145 11/14/2020
2.4.5 264,669 11/17/2020
2.4.4 323,539 8/25/2020
2.4.3 251,023 3/25/2020
2.4.2 59,050 2/25/2020
2.4.1 207,839 10/16/2019
2.4.0 178,988 9/15/2019
2.3.0 81,540 7/10/2019
2.2.4 86,281 6/15/2019
2.2.3 13,195 5/25/2019
2.2.2 10,012 5/17/2019
2.2.0 66,834 5/16/2019
2.1.14 16,915 5/3/2019
2.1.13 10,741 4/21/2019
2.1.12 43,317 12/31/2018
2.1.11 2,021 12/30/2018
2.1.10 232,445 9/22/2018
2.1.9 25,261 9/16/2018
2.1.8 72,465 6/18/2018
2.1.7 3,759 6/12/2018
2.1.5 100,840 5/30/2018
2.1.3 2,231 5/29/2018
2.1.2 4,316 5/24/2018
2.1.1 12,219 5/23/2018
2.1.0.7 44,776 4/2/2018
2.1.0.6 2,559 3/26/2018
2.1.0.5 5,202 3/8/2018
2.1.0.4 2,488 3/5/2018
2.1.0.3 2,183 3/5/2018
2.1.0.2 29,357 1/19/2018
2.1.0.1 9,737 1/3/2018
2.1.0 142,037 12/15/2017
2.0.4 2,125 12/12/2017
2.0.2 25,527 9/7/2017
2.0.1 32,708 8/19/2017
2.0.0 6,511 8/15/2017
2.0.0-beta1 2,847 7/12/2017
1.1.1.12 12,118 7/8/2017
1.1.1.11 2,075 7/8/2017
1.1.1.10 8,213 5/20/2017
1.1.1.9 2,139 5/20/2017
1.1.1.8 3,860 4/20/2017
1.1.1.7 6,891 3/18/2017
1.1.1.6 10,448 3/16/2017
1.1.1.5 2,699 3/7/2017
1.1.1.4 2,358 3/7/2017
1.1.1.3 13,851 1/2/2017
1.1.1.2 2,333 12/24/2016
1.1.1.1 2,984 12/20/2016
1.1.1 2,624 12/10/2016
1.1.0.2 2,658 12/10/2016
1.1.0.1 2,453 12/8/2016
1.1.0 2,446 12/5/2016
1.0.0.8 6,881 11/11/2016
1.0.0.7-preview1 2,183 10/26/2016
1.0.0.6 5,857 10/20/2016
1.0.0.5 2,237 10/19/2016
1.0.0.4 2,244 10/18/2016
1.0.0.3 2,258 10/13/2016
1.0.0.2 2,286 9/27/2016
1.0.0.1 2,338 9/26/2016
1.0.0 3,450 3/25/2016