문제

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:

  <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 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

JP

도움이 되었습니까?

해결책

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

다른 팁

If anyone is still looking for a solution,

You can use https://github.com/henriquecampos/NHibernate.Caches.Elasticache for connecting to Amazon Elastic Cache with very less configuration.

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

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

ie:

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

Its a aws issue hostnames(those provided by amazon, amazon-XXXX) are not applicable as they not mapped to any domain.

Routing between internal ips also dont seem possible, you can try tracing it it goes everywhere. Only way is to use the external facing elastic ips as you found out,

Routing to cnames mapped to amazon also dont seem possible

you can try submitting a reverse dns mapping request (at the amazon faq), or set secondary dns request (disclaimer, i didnt try both, i mapped using the elastic ip and had to move on to more urgent things)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top