JP. JP. - 24 days ago 11
C# Question

Issues using NHibernate memcached 2nd level cache with AWS Elasticache

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

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

Elasticache on the other hand provides a static host name for cache clusters and it is not recommended to use internal IP addresses as these are prone to change.

Has anyone been able to use the NHibernate memcached provider with Elasticache? Are there alternate ways to configure memcached with NHibernate such that it uses a host name rather than IP address?

Thank you


Answer Source

For anyone interested: I was unable to point to the hostname using NHibernate.Caches.MemCache. However, it turns out there is an alternate memcache implementation for NHibernate - NHibernate.Caches.EnyimMemcached. This allows servers to be defined by IP address or host name, solving my issue. I'd still be interested to hear if it is possible to achieve using the older Memcache integration but things are working nicely with EnyimMemcached