Problems Using NHibernate Layer 2 Cache with AWS Elasticache

I use memcached as my second level NHibernate cache. I am moving my system to Amazon Web Services and plan to use Elasticache, which is fully compatible with Memcache. Memcached uses a set of host IP addresses (note: not host names - the library throws an error if it detects an invalid IP address string) to connect to memcached servers. The following is an example configuration line:

<memcache> <memcached host="192.168.1.1" port="11211" expiration="300" /> </memcache> 

Elasticache, on the other hand, provides a static host name for cache clusters, and internal IP addresses are not recommended, as they are subject to change.

Could anyone use the NHibernate memcached provider with Elasticache? Are there alternative ways to configure memcached with NHibernate so that it uses the host name instead of the IP address?

thanks

In JP

+4
source share
4 answers

For everyone who is interested: I could not point to the host name using NHibernate.Caches.MemCache. However, it turns out that there is an alternative implementation of memcache for NHibernate - NHibernate.Caches.EnyimMemcached. This allows me to identify servers by IP address or host name, solving my problem. I would still be interested to hear if it is possible to achieve using the older Memcache integration, but everything works well with EnyimMemcached.

+3
source

If someone is still looking for a solution,

You can use https://github.com/henriquecampos/NHibernate.Caches.Elasticache to connect to Amazon Elastic Cache with a very smaller configuration.

Also for local development you can use the following project https://github.com/hybridtechie/fake-elasticache-.NET-version

+1
source

Instead of using the host attribute in your configuration file, can you not just use the hostname attribute and set it to the DNS name provided by ElastiCache?

t

 <memcached hostname="simcoprod02.m2st2p.fsw4.use1qa.cache.amazonaws.com" port="11211" expiration="300" /> 
0
source

Its problem aws host names (those provided by amazon, amazon-XXXX) are not applicable since they do not map to any domain.

Routing between internal ips is also not possible, you can try to track it, it is everywhere. The only way is to use external elastic ips, as you know,

Routing in cnames mapped to amazon is also not possible

you can try to send a request for reverse dns matching (in amazon faq) or ask a secondary dns request (disclaimer, I have not tried both, I matched using elastic ip and had to go to more urgent things)

-1
source

All Articles