简体   繁体   English

使用AWS Elasticache的NHibernate memcached二级缓存的问题

[英]Issues using NHibernate memcached 2nd level cache with AWS Elasticache

I uses memcached as my NHibernate 2nd level cache. 我使用memcached作为我的NHibernate二级缓存。 I am moving my system to Amazon Web Services and plan to use Elasticache which is fully Memcache compatible. 我正在将我的系统移动到Amazon Web Services并计划使用完全兼容Memcache的Elasticache。 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. Memcached使用一组主机IP地址 (注意:不是主机名 - 如果检测到无效的IP字符串,则库会引发错误)以连接到memcached服务器。 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. 另一方面,Elasticache为缓存集群提供静态主机名,建议不要使用内部IP地址,因为这些地址很容易发生变化。

Has anyone been able to use the NHibernate memcached provider with Elasticache? 有没有人能够使用Elasticache的NHibernate memcached提供程序? Are there alternate ways to configure memcached with NHibernate such that it uses a host name rather than IP address? 是否有其他方法可以使用NHibernate配置memcached,使其使用主机名而不是IP地址?

Thank you 谢谢

JP J.P

For anyone interested: I was unable to point to the hostname using NHibernate.Caches.MemCache. 对于任何感兴趣的人:我无法使用NHibernate.Caches.MemCache指向主机名。 However, it turns out there is an alternate memcache implementation for NHibernate - NHibernate.Caches.EnyimMemcached. 然而,事实证明NHibernate有一个备用的memcache实现 - NHibernate.Caches.EnyimMemcached。 This allows servers to be defined by IP address or host name, solving my issue. 这允许服务器由IP地址或主机名定义,解决了我的问题。 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 我仍然有兴趣听听是否可能使用旧的Memcache集成,但事情与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. 您可以使用https://github.com/henriquecampos/NHibernate.Caches.Elasticache以极少的配置连接到Amazon Elastic Cache。

Also for the local development, you can use the following project https://github.com/hybridtechie/fake-elasticache-.NET-version 同样对于本地开发,您可以使用以下项目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? 您是否可以使用hostname属性并将其设置为ElastiCache提供的DNS名称,而不是在配置文件中使用host属性?

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. 它的aws问题主机名(由amazon,amazon-XXXX提供的那些)不适用,因为它们没有映射到任何域。

Routing between internal ips also dont seem possible, you can try tracing it it goes everywhere. 内部ips之间的路由似乎也不可能,您可以尝试跟踪它到处都是。 Only way is to use the external facing elastic ips as you found out, 唯一的方法是使用外部饰面弹性ips,如你所知,

Routing to cnames mapped to amazon also dont seem possible 路由到映射到亚马逊的cnames似乎也不可能

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) 您可以尝试提交反向DNS映射请求(在amazon faq),或设置辅助DNS请求(免责声明,我没有尝试两者,我使用弹性IP映射,不得不继续更紧急的事情)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM