Giter Club home page Giter Club logo

enyimmemcachedcore's People

Contributors

andrew-vant avatar asaintsever avatar bcuff avatar catcherwong avatar ciaranj avatar cnblogs-dudu avatar cnblogstim avatar echofool avatar enyim avatar gonyoda avatar greatkeke avatar greggbjensen avatar hazzik avatar iamkrillin avatar ikesnowy avatar jzablocki avatar keke-cnblogs avatar kt81 avatar mausch avatar mfenniak avatar mikeleedev avatar nathanbaulch avatar noonamer avatar ratosh avatar romanpolunin avatar vytautask avatar zeekozhu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enyimmemcachedcore's Issues

If using a hostname to connect with DefaultNodeLocator, results in different server lookup hashing over classic enyim

If you are using a hostname to connect to memcache such as myelasticcache.number.usw2.cache.amazonaws.com, this results in the host name being used to generate keys to lookup servers with. Classic enyim resolves the host name and then uses the IP address. Because of this difference, this version will choose different nodes for getting / setting memcache values. If you are using both dotnetcore and enyim in the same environment e.g. your main web servers run on windows in IIS and you do background work in AWS Lambda, this difference causes major problems.

In this version of IMemcachedNode.cs a System.Net.EndPoint is used while in the regular version of Enyim it is a System.Net.IPEndPoint.

What was the reason for not using an IPEndPoint like regular Enyim? Why was this change made? 6b78cf5

how to configure multi server?

I want use this to store data in multi server,but always just store in one

is that need some code to config?

I just add a config in appsettings.json

"Memcached": {
    "Servers": [
      {
        "Address": "39.108.125.154",
        "Port": 11211
      },
      {
        "Address": "39.108.125.154",
        "Port": 11210
      }
    ]
  }
}

Please provide a way to easily instantiate a MemcachedClient

At the moment, the implementation and all the examples are geared toward injecting Memcached into middleware and its usage as DI.

But imagine the following project structure. Widget.UI project (MVC) calls Widget.Business calls Widget.Services calls Widget.Repository. Let's say I want to implement distributed caching in Widget.Repository (last project in the chain). I'd have to build constructors to accept Memcached client from Widget.Business all the way down to Widget.Repository.

This would make usage of the intermediate projects from other places in code difficult to say the least.

I understand that I can create a Memcached instance via GenericHost approach. I don't think that's a good way to go because I am building out an entire host infrastructure in a class that doesn't know anything about that.

Please provide a constructor to enable something similar to the following:

var options = new MemcachedOptions {.Servers = "11.22.33.44"};
var cache = new MemcachedClient(options);

Touch support?

Is there anyway to do a touch with the library as-is? I want to extend the duration of a key's existence without replacing it entirely if possible.

Write error throws Exception without internal catch

Read operation returns result object that be marked as failed or null when it fails.
But write operation throws System.Exception in same situation.

imo, it should throws System.IO.IOException instead of Exception so that MemcachedNode may catch it.

更新到2.1.10版本时,出现读取缓存错误

运行环境

  • ubuntu 16.04

Core版本

  • 2.2.0

EnyimMemcachedCore版本

  • 2.1.10

错误日志

2018-12-27 01:01:00.927 +08:00 [Error] GetAsync("test-cachekey")
System.ArgumentOutOfRangeException: Unexpected BsonType value: 0
Parameter name: type
   at Newtonsoft.Json.Bson.BsonDataReader.ReadType(BsonType type)
   at Newtonsoft.Json.Bson.BsonDataReader.ReadNormal()
   at Newtonsoft.Json.Bson.BsonDataReader.Read()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader)
   at Enyim.Caching.Memcached.DefaultTranscoder.Deserialize[T](CacheItem item)
   at Enyim.Caching.MemcachedClient.BuildGetCommandResult[T](IGetOperationResult`1 result, IGetOperation command, IOperationResult commandResult)
   at Enyim.Caching.MemcachedClient.GetAsync[T](String key)

.net core 2.0 启动时报错

fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[24311045]
Create PooledSocket
System.TimeoutException: Could not connect to Unspecified/memcached:11211
at Enyim.Caching.Memcached.PooledSocket.ConnectWithTimeout(Socket socket, EndPoint endpoint, Int32 timeout)
at Enyim.Caching.Memcached.PooledSocket..ctor(EndPoint endpoint, TimeSpan connectionTimeout, TimeSpan receiveTimeout, ILogger logger)
at Enyim.Caching.Memcached.MemcachedNode.CreateSocket()
fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[0]
Could not init pool.
warn: Enyim.Caching.Configuration.MemcachedClientConfiguration[0]
Marking node Unspecified/memcached:11211 as dead
EnyimMemcached Started.
Hosting environment: Development

Expire seconds setting not work

How to reproduce?
just run test case:
Test Name: MemcachedTest.BinaryMemcachedClientTest.StoreStringTest
Test FullName: MemcachedTest.BinaryMemcachedClientTest.StoreStringTest

asp.net core程序启动后,有大量请求进来时,线程死锁

先上图片:
image

我的core api是跑在容器中的,偶尔有时候,docker run起来之后,整个api就hang住了,其他所有接口都无法响应。
然后我用lldb调试下,发现有个线程死锁了,跟进去一看,就是上面的图片。

因为这个问题在生产环境上很容易复现,生产环境并发量还是挺大的;但是这个问题在测试环境中从来没有复现过(没有请求量)。

我用的clinet版本为:
image

Doesn't seem to run using .NET Standard 2.0 Preview

Hello,

There's a missing method exception when using EnyimMemcachedCore together with 2.0.0-preview2-final:

System.MissingMethodException : Method not found: 'System.Threading.Tasks.Task`1<Byte[]> Microsoft.Extensions.Caching.Distributed.IDistributedCache.GetAsync(System.String)'.

Any chance this could be fixed?

GetValueAsync<> always failed with "unable to locate node with key"

GetValueAsync<> always failed with unable to locate node with key under high concurrency.

A simple reproduce: https://github.com/ZeekoZhu/memcachedcore-stress

Here is the output on my computer:

Use GetValueAsync
Single Run: 1/1/01 8:05:00 AM
Single Run: 1/1/01 8:05:00 AM
Time: 21458ms
Error Cnt: 999988
Avg: 0.021458ms
Use Get
Single Run: 1/1/01 8:05:00 AM
Single Run: 1/1/01 8:05:00 AM
Time: 25200ms
Error Cnt: 0
Avg: 0.0252ms

Get<> is much more reliable than GetValueAsync<>

Release 1.1.0 causes NullReferenceException in AddServer when running in AWS

Upon upgrading to the latest release, 1.1.0 I am getting an exception when initializing memcached and adding a server. This code has been working without issue and the only change I made was updating this package. Here is the code to setup Memcached which is causing the problem:

            var memcachedClientLogger = _loggerFactory.CreateLogger&lt;MemcachedClient&gt;();
            var options = Options.Create(new MemcachedClientOptions());
            var config = new MemcachedClientConfiguration(memcachedClientLogger, options);
            foreach (var node in CacheNodes)
            {
                Logger.Debug("Adding memcache server node {0}:{1} to configuration", node.Endpoint.Address,
                    node.Endpoint.Port);
                config.AddServer(node.Endpoint.Address, node.Endpoint.Port);   //Line 83 in the stacktrace below
            }

I get NRE with this stack trace:

System.NullReferenceException: Object reference not set to an instance of an object. at Enyim.Caching.Configuration.ConfigurationHelper.ResolveToEndPoint(String host, Int32 port) at Enyim.Caching.Configuration.MemcachedClientConfiguration.AddServer(String host, Int32 port) at Foo.AWS.ElastiCache.ElastiCacheService.d__8.MoveNext() in /src/Foo.AWS/ElastiCache/ElasticCacheService.cs:line 83 --- End of stack trace from previous location where exception was thrown --- .....

The logged message before calling AddServer is:

Adding memcache server node XXXXXX.uiezb6.0001.use1.cache.amazonaws.com:11211 to configuration

This appears to be related to commit dc5cf83, which was the most recent change prior to releasing 1.1.0.

Updated Tests and Examples

Glad to see this port but the tests and examples should be updated to reflect changes that have been made.

Nuget package version error?

When I want to use FlushAllAsync in my code, this api should work in version 2.1.0.6 but I can not find this api via VS!

I use Go To Definition to see the interface IMemcachedClient, I also can not find out this api as well!

And I notice the summary which makes me confuse here!

1

Is there something wrong about version 2.1.0.6 ?

Address is misspelled in appsettings.json

This is a great library you have put together. I ran into one minor issue blow, which is that you have to misspell Addess to get it to work.

{
  "enyimMemcached": {
    "Servers": [
      {
        "Addess": "memcached",
        "Port": 11211
      }
    ]
  }
}

BSON does not support unsigned values.

BSON does not support unsigned types, if the number larger than signed type max value, it throws exception:

Value is too large to fit in a signed 32 bit integer. BSON does not support unsigned values.

Getting memcached server status

Hi!

I am trying to get the server status from the memcache client using its method Stats().

ServerStats status = MemCachedClient.Stats();

To get the server status info you need to use the next method:

GetRaw(IPEndPoint server, string key)

So I created an IPEndPoint object and used it as a parameter:

var uptime = status .GetRaw(new IPEndPoint(IPAddress.Parse("XXX.XXX.XX.XX"), 11211), "uptime");

The problem is that the IPEndPoint that I instanciated and passed as a parameter and the IPEndPoint that is inside the ServerStats class have different AddressFamily.

new IPEndPoint() -> AddressFamily = InterNetwork
IPEndPoint inside the ServerStats -> AddressFamily = Unspecified

So when I do GetRaw(), it does not find the IPEndPoint because the AddresFamily is different.

Is there any way to get the server status info?

Thanks!

Error reading memcache set with expiry

Error reading memcache with expiry
i stored/write memcache with below code but not able to read with key

MemcachedClient.Store(StoreMode.Set, "abc", "10",new TimeSpan(0,23, 0, 0));

I tried with two methods, timespan and datetime

Client Infinitely Hangs Following Memcached Server Reset

When running a dotnet core application with the EnyimMemcached client service registered, if one of the connected servers is stopped and restarted, the IMemcachedClient instance hangs infinitely when calling StoreAsync on the client instance. The last log that comes from from Enyim.Caching.Configuration.MemcachedClientConfiguration is "Socket was reset. (socket GUID)".

Here's the easiest way to reproduce the problem

  • Create a local Memcached Docker container by running the command docker run --name my-memcache -p 127.0.0.1:11211:11211 -d memcached memcached -m 64
  • Create a new dotnet core web application
  • Add the EnyimMemcachedCore NuGet package to the application
  • Register the EnyinMemcached service in the Startup.cs. This is how I'm doing it in mine:
public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddEnyimMemcached((cacheConfig) =>
    {
        //Add servers (point to Docker container on the port forwarded to localhost)
        cacheConfig.AddServer("127.0.0.1", 11211);
    });
    ...
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    ...
    app.UseEnyimMemcached();
    ...
}
  • Now write a controller that takes and IMemcachedClient constructor parameter
  • In the controller add an implementation that makes a call to the IMemcachedClient StoreAsync method
  • Run the application and make sure everything is wired and working properly
  • Now run the docker stop my-memcache command to stop the Memcached Docker container then run docker start my-memcache to get it running again
  • Without ever shutting down the dotnet core application, go back and re-execute the method that calls StoreAsync
  • The logger will write a log indicating that Enyim.Caching.Configuration.MemcachedClientConfiguration is "Aquiring stream from pool..." and then another message will log saying that "Socket (GUID) was reset". After that it will write a log of "Socket was reset. (GUID)".
    At this point the request (and any subsequent session requests) will be hung indefinitely. The only thing that can be done is to restart the application.

Error entry in log

_memcachedClient.Store(StoreMode.Set, key, value);

Sometimes when i setting the value to cache - the log gets a record with text

Enyim.Caching.MemcachedClient
PerformStore

what is this error?

Unexpected BsonType

When running on Amazon Elasticache (memcached 1.5.10) I get the below error, since recently. Running locally on my machine works, no errors. Any ideas?

System.ArgumentOutOfRangeException: Unexpected BsonType value: 0 Parameter name: type at Newtonsoft.Json.Bson.BsonDataReader.ReadType(BsonType type) at Newtonsoft.Json.Bson.BsonDataReader.ReadNormal() at Newtonsoft.Json.Bson.BsonDataReader.Read() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader) at Enyim.Caching.Memcached.DefaultTranscoder.Deserialize[T](CacheItem item) at Enyim.Caching.MemcachedClient.BuildGetCommandResult[T](IGetOperationResult1 result, IGetOperation command, IOperationResult commandResult)
at Enyim.Caching.MemcachedClient.GetAsync[T](String key)`

Not possible to set custom transcoder?

It appears it's not possible to set a custom transcoder.

It looks like this would need to be added to MemcachedClientOptions and then picked up by MemcachedClientConfiguration?

How to turn on logging

How do I turn on logging for EnyimMemcachedCore? StoreAsync is returning false, but I don't know why.

The difference between Get(string key) and Get<T>(string key)

I set the value of a key "foo" to empty string. If I use IDistributedCache interface, cache.Get("foo") returns null; if I use IMemcachedClient, cache.Get("foo") returns byte[] correctly.

Digging into the code, looks IDistributedCache.Get calls Get<T>(). Why Get() and Get<T>() handles empty value differently?

Error during deserilization dictionary

I need to cache the dictionary

var dict = new Dictionary<int, HashSet<int>>();
dict.Add(1, new HashSet<int> { 1, 2, 3 });
dict.Add(2, new HashSet<int> { 4, 5, 6 });

var key = "dict_key";
_cacheClient.Store(StoreMode.Set, key, dict);
var obj = _cacheClient.Get<Dictionary<int, HashSet<int>>>(key); <-- this error

Error Message = "Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary[System.Int32,System.Collections.Generic.HashSet[System.Int32]]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize...`

But Dictionary<TKey, TValue> is ISerializable.

can you tag all your releases moving forward?

Under releases there is only a tag for 2.1.9 your most current release. This makes trying to figure out what changed between 2.1.8 really hard...You should keep a tag every time you release a nuget package that way it is easy for people to stick with a version or help you track down bugs that come out in future releases.

Where are the tags for 2.1.3, 2.1.5, 2.1.7, 2.1.8?

I set a string value in donet core ,when i get value in asp.net webapi, throw a Exception

值对于 UInt16 太大或太小。
在 System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info)
在 Enyim.Caching.Memcached.Protocol.Text.GetHelper.ReadItem(PooledSocket socket)
在 Enyim.Caching.Memcached.Protocol.Text.GetOperation.ReadResponse(PooledSocket socket)
在 Enyim.Caching.Memcached.MemcachedNode.ExecuteOperation(IOperation op)
在 Enyim.Caching.MemcachedClient.PerformTryGet(String key, UInt64& cas, Object& value)
在 Enyim.Caching.MemcachedClient.TryGet(String key, Object& value)
在 Enyim.Caching.MemcachedClient.Get(String key)

Amazon.ElastiCacheCluster

Hi, I am connecting to AWS ElasticCache Cluster, do this package support Amazon.ElastiCacheCluster .NET version?

More time taken to read/write to Memcache cluster

Hi,

I am Reading/Writing data to AWS Memcache cluster using EnyimMemcachedCore, i see a more time taken Read/Write. I am using AWS Lambda to connect to AWS Memcache cluster adding the log details + Configuration file

Log information

08:26:44 START RequestId: 176fd016-af53-11e8-8c00-57c04b9a2f1a Version: $LATEST
08:26:56 Time taken to add item in cache - 10074 milliseconds.
08:27:06 Time taken to read item from cache - 10033 milliseconds.
08:27:16 Time taken to add item in cache - 10021 milliseconds.
08:27:16 END RequestId: 176fd016-af53-11e8-8c00-57c04b9a2f1a

Configuration

{
"enyimMemcached": {
"Servers": [
{
"Address": "REMOVED_THE_SERVERNAME.cache.amazonaws.com",
"Port": 11211
},
{
"Address": "REMOVED_THE_SERVERNAME.cache.amazonaws.com",
"Port": 11211
},
{
"Address": "REMOVED_THE_SERVERNAME.cache.amazonaws.com",
"Port": 11211
},
{
"Address": "REMOVED_THE_SERVERNAME.cache.amazonaws.com",
"Port": 11211
}
],
"socketPool": {
"minPoolSize": "1",
"maxPoolSize": "100",
"connectionTimeout": "00:00:10",
"receiveTimeout": "00:00:15",
"deadTimeout": "00:02:00",
"queueTimeout": "00:00:00.150"
}
},

"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Warning",
"Microsoft": "Warning"
}
}
}

为啥执行运行示例,取不到缓存的内容

      public async Task<IActionResult> Index()
       {
           _logger.LogDebug("Executing _memcachedClient.GetValueOrCreateAsync...");
           var cacheSeconds = 2000;
           var posts = await _memcachedClient.GetValueOrCreateAsync(
               CacheKey,
               cacheSeconds,
               async () => await _blogPostService.GetRecent(10));

           _logger.LogDebug("Done _memcachedClient.GetValueOrCreateAsync");

           return Ok(posts);
       }

测试的时候每次都会进入 await _blogPostService.GetRecent(10)); 这个子方法。

Performance when setting a key

The memcached wiki states the following:

On a good day memcached can serve requests in less than a millisecond. After accounting for outliers due to OS jitter, CPU scheduling, or network jitter, very few commands should take more than a millisecond or two to complete.

I am testing to see how long it takes to get/set key and getting on average 63ms for set and 5ms for get. The set is what I am concerned about. 63ms seems a lot. To be fair, that's the first Set. All the consequent Set operations are fast. Is there some initialization happening that I can handle elsewhere?

The servers that I connect to are not doing anything at all. There is plenty of CPU.

The code is below - it's a .NET Core Console app. I am running my test from a Windows Server 2016 x64. The version of the library is 2.1.14. I've ran ping against the memcached boxes and its under a 1 ms.

How do I go about examining where the bottleneck is? Is it the library?

static void Main(string[] args) {
    MemcachedClient client = Create();

    string key = "foobar-123-9333";
    string value = RandomString(1000);

    // measure Set
    Stopwatch s = Stopwatch.StartNew();
    client.Set(key, value, 1000);
    Console.WriteLine($"Set {s.ElapsedMilliseconds} ms");

    // measure Get
    s = Stopwatch.StartNew();
    string data = client.Get<string>(key);
    Console.WriteLine($"Get {s.ElapsedMilliseconds} ms");
}

static MemcachedClient Create() {
    var loggerFactory = new Microsoft.Extensions.Logging.Abstractions.NullLoggerFactory();
    var options = new MemcachedClientOptions();
    options.Servers.Add(new Server { Address = "10.147.24.9", Port = 11211 });
    options.Servers.Add(new Server { Address = "10.147.24.10", Port = 11211 });

    var configuration = new MemcachedClientConfiguration(loggerFactory, options);
    return new MemcachedClient(loggerFactory, configuration);
}

private static Random random = new Random();
public static string RandomString(int length) {
    const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    return new string(Enumerable.Repeat(chars, length)
      .Select(s => s[random.Next(s.Length)]).ToArray());
}

ArgumentOutOfRangeException thrown when setting MinPoolSize and MaxPoolSize programmatically

It appears a bug is introduced in 2.0.4+ when MinPoolSize and MaxPoolSize are set via SocketPoolOptions (MemcachedClientOptions.cs) and MinPoolSize property in SocketPoolConfiguration.cs has a check to ensure it's less than MaxPoolSize. The issue is when both properties are set in SocketPoolOptions, it will throw ArgumentOutOfRangeException since the default values are 10 and 20 respectively and when I set 50 and 500, it will check MinPoolSize (50) against MaxPoolSize (20). It does not know about the new value yet.

Here's the example that will trigger the exception.

var c = new SocketPoolOptions { MinPoolSize = 50, MaxPoolSize = 500 };
var options = Options.Create(new MemcachedClientOptions { SocketPool = c });
var config = new MemcachedClientConfiguration(_loggerFactory, options);

how to set the key transformer

Sorry I dont know that this is a correct place to ask this question or not:
how is possible to set the ke transformer type in the .net frame work version it was like this :

<enyim.com>
      <memcached>
        <servers>
          <add address="neptune" port="11217" />
        </servers>
        <socketPool maxPoolSize="200" />
        <keyTransformer type="Enyim.Caching.Memcached.TigerHashKeyTransformer, Enyim.Caching" />
      </memcached>
    </enyim.com>

but in .net core how can I set it in the config file. I can set my servers and ports but dont know how to set the keyTransformer

System.PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt

Hi,
I'm getting an error after upgrade EnyimMemcachedCore to 2.1.7 (.NET Core 2.1).

The error occurs when run it on Linux machine in docker, memcached served on another Linux machine if it matters. Running application locally on Windows it works well (no docker).

And it was working fine on version 2.1.2 targeting on .NET Core 2.0 both Linux and Windows.

fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[33323423],
      Create PooledSocket,
System.PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt.,
   at System.Net.Sockets.Socket.ThrowMultiConnectNotSupported(),
   at System.Net.Sockets.Socket.ConnectAsync(SocketAsyncEventArgs e),
   at Enyim.Caching.Memcached.PooledSocket.ConnectWithTimeout(Socket socket, DnsEndPoint endpoint, Int32 timeout),
   at Enyim.Caching.Memcached.PooledSocket..ctor(DnsEndPoint endpoint, TimeSpan connectionTimeout, TimeSpan receiveTimeout, ILogger logger),
   at Enyim.Caching.Memcached.MemcachedNode.CreateSocket(),
fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[33323423],
      Create PooledSocket,
System.PlatformNotSupportedException: Sockets on this platform are invalid for use after a failed connection attempt.,
   at System.Net.Sockets.Socket.ThrowMultiConnectNotSupported(),
   at System.Net.Sockets.Socket.ConnectAsync(SocketAsyncEventArgs e),
   at Enyim.Caching.Memcached.PooledSocket.ConnectWithTimeout(Socket socket, DnsEndPoint endpoint, Int32 timeout),
   at Enyim.Caching.Memcached.PooledSocket..ctor(DnsEndPoint endpoint, TimeSpan connectionTimeout, TimeSpan receiveTimeout, ILogger logger),
   at Enyim.Caching.Memcached.MemcachedNode.CreateSocket(),
fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[0],
      Could not init pool.,
fail: Enyim.Caching.Configuration.MemcachedClientConfiguration[0],
      Could not init pool.,
warn: Enyim.Caching.Configuration.MemcachedClientConfiguration[0],
      Marking node Unspecified/xxx.xxx.xx.xx:11211 as dead,
warn: Enyim.Caching.Configuration.MemcachedClientConfiguration[0],
      Marking node Unspecified/xxx.xxx.xx.xx::11211 as dead,
EnyimMemcached Started.,
Hosting environment: Production,
Content root path: /app,
Now listening on: http://0.0.0.0:5000,
Application started. Press Ctrl+C to shut down.,

Configuration from appsettings:

"enyimMemcached": {
    "Servers": [
      {
        "Address": "xxx.xxx.xx.xx:",
        "Port": 11211
      }
    ],
    "socketPool": {
      "minPoolSize": "5",
      "maxPoolSize": "25",
      "connectionTimeout": "00:00:15",
      "receiveTimeout": "00:00:15",
      "deadTimeout": "00:00:15",
      "queueTimeout": "00:00:00.150"
    },
    "KeyTransformer": "Enyim.Caching.Memcached.SHA1KeyTransformer, EnyimMemcachedCore",
    "Transcoder": "ProtoBuf.Caching.Enyim.NetTranscoder, protobuf-net.Enyim"
  }

MemcachedClient.Remove fails to remove items from cache

EnyimMemcachedCore v2.1.8

ExecuteRemoveAsync doesn't hash the key before determine the pool node. Therefore, the remove always fails.

public async Task<IRemoveOperationResult> ExecuteRemoveAsync(string key)
    {
      IMemcachedNode memcachedNode = this.pool.Locate(key);

should be:

public async Task<IRemoveOperationResult> ExecuteRemoveAsync(string key)
    {
      string hashedKey = this.keyTransformer.Transform(key); 
      IMemcachedNode memcachedNode = this.pool.Locate(hashedKey );

And similar for the non-async version. And, hashedKey needs to be passed to OperationFactory.Delete later in the method(s).

The key is hashed in the PerformStoreAsync and PerformTryGet.

I'd make a PR to help out, but I'm not sure which branch to work off.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.