0

I haven't been able to find many decent examples of how to use AWS Elasticache from c#.

http://jacace.wordpress.com/2013/02/24/using-the-amazon-elasticache-in-c/ suggested the BeIT library, which I am trying.

Here's my code so far:

        string memCachedUrl = "mycache.xxxxxx.cfg.use1.cache.amazonaws.com:11211";
        MemcachedClient.Setup("mycache", new string[] { memCachedUrl });
        MemcachedClient cache = MemcachedClient.GetInstance("mycache");

        aData n = new aData();
        cache.Set("aData",1234);

and the error I get is:

29/05/2013 9:52:19 AM ERROR BeIT.MemCached.SocketPool - Error connecting to: 54. 
243.16.75 
The operation completed successfully
at BeIT.MemCached.PooledSocket..ctor(SocketPool socketPool, IPEndPoint endPoint, Int32 endReceiveTimeout, Int32 connectTimeout) in l:\Projects\BeITMemcached
\ClientLibrary\PooledSocket.cs:line 63 
at BeIT.MemCached.SocketPool.Acquire() in l:\Projects\BeITMemcached\ClientLibrary\SocketPool.cs:line 151

what am I doing wrong? Is there any good sample c# code anywhere?

UPDATE

I was trying to call this from outside AWS - apparently this is not possible

mcmillab
  • 2,752
  • 2
  • 23
  • 37
  • Elastic cache is just memcached. Any information on how to connect to memcached will work. In this case, you might need to check your security group settings though. – datasage May 29 '13 at 04:16
  • I'd thought of that, but as far as I can tell my security settings allow all IP addresses on all ports (its just a test). Anything else I need to change there? – mcmillab May 29 '13 at 04:46
  • I was trying to use ElastiCache from outside AWS - apparently this is not possible – mcmillab May 30 '13 at 23:08
  • There is not much advantage to using elastic cache outside of AWS. Network latency would kill any advantage gained by using memcached. If you want to test it outside of aws, just install memcached. – datasage May 30 '13 at 23:27
  • I am also trying to do the same. Please let me know the final conclusion on this. – VJOY Jan 13 '14 at 08:06
  • my conclusion is above - it doesn't work outside of AWS, therefore I stopped using it. – mcmillab Jan 13 '14 at 15:07

2 Answers2

1

I realize this is an older question however I had issues and could not find good examples of how to successfully implement ElastiCache with Memcached flavor in my C# application so I built a library that you can easily use for yours. I hope this helps someone out.

One thing to reiterate as you have already stated is that you cannot access your nodes outside of Amazon.

AWS C# ElastiCache

Keenan
  • 264
  • 3
  • 7
1

If the reason to do this is for testing purposes, the service discovery piece is pretty easy to fake. Make an http listener that responds to "config get" with info describing a local Memcached node.

Easy to see what the client is doing: https://github.com/awslabs/elasticache-cluster-config-net Amazon.ElastiCacheCluster/Operations/ConfigGetOperation.cs