How to configure EnyimMemcachedCore to access Elasticache in AWS Lambda?

I am trying to transfer a simple memcached client from .NET 4 to .Net Core on AWS Lambda. I am trying to set up a new EnyimMemcachedCore client because the examples ( https://github.com/cnblogs/EnyimMemcachedCore ) use appsettings.json to configure, but the Lambda functions use .net does not use appsettings.json. I need to configure server / port / endpoint in C # code.

Can someone give me an example using EnyimMemcachedCore, which creates the configuration manually?

The standard use of Enny Ennet was trivial to fetch by key and return a value:

using Enyim.Caching;
using Enyim.Caching.Configuration;
using Enyim.Caching.Memcached;

...
// setup Enyim memcached client
MemcachedClient myCache;
MemcachedClientConfiguration config;
config = new MemcachedClientConfiguration(); 
config.AddServer("theIP", thePort);
config.Protocol = MemcachedProtocol.Text;

// instantiate client
myCache = new MemcachedClient(config);

// get the stored item
var result = myCache.Get(key);

How do I do something like this (configure the memcached client in code, not in the configuration file) with EnyimMemcachedCore?

+4
1
// setup Enyim memcached client
var config = new MemcachedClientConfiguration();

//add each node manually if you can't get the Amazon.ElastiCacheCluster config for Core, 
//but if you can, use that instead of MemcachedClientConfiguration
config.AddServer("something.0001.usw1.cache.amazonaws.com", 11211);
config.AddServer("something.0002.usw1.cache.amazonaws.com", 11211);

config.Protocol = MemcachedProtocol.Text;

// instantiate client
var myCache = new Enyim.Caching.MemcachedClient(config);

, .NET Core ( )

+1

Source: https://habr.com/ru/post/1681551/


All Articles