[英]Sharing nHibernate and hibernate 2nd level cache
Is it possible to share the 2nd level cache between a hibernate and nhibernate solution? 是否可以在hibernate和nhibernate解决方案之间共享二级缓存? I have an environment where there are servers running .net and servers running java who both access the same database.
我有一个环境,其中有运行.net的服务器和运行java的服务器都访问同一个数据库。
there is some overlap in the data they access, so sharing a 2nd level cache would be desirable. 他们访问的数据存在一些重叠,因此需要共享二级缓存。 Is it possible?
可能吗?
If this is not possible, what are some of the solutions other have come up with? 如果这是不可能的,那么其他一些解决方案有哪些?
There is some overlap in the data they access, so sharing a 2nd level cache would be desirable.
他们访问的数据存在一些重叠,因此需要共享二级缓存。 Is it possible?
可能吗?
This would require (and this is very likely oversimplified): 这将需要(这很可能过于简化):
This sounds feasible but: 这听起来可行但是:
If this is not possible, what are some of the solutions other have come up with?
如果这是不可能的,那么其他一些解决方案有哪些?
I never had to do this but if we're talking about a read-write cache and if you use two separate caches, you'll have to invalidate a given Java cache region from the .Net side and inversely. 我从来没有这样做,但如果我们谈论的是读写缓存,并且如果你使用两个独立的缓存,你将不得不从.Net方面反过来使给定的Java缓存区域无效。 You'll have to write the code to handle that.
你必须编写代码来处理它。
As Pascal said, it's improbable that sharing the 2nd cache is technically possible. 正如Pascal所说,共享第二个缓存在技术上是不可能的。
However, you can think about this from a different perspective. 但是,您可以从不同的角度思考这个问题。
It's unlikely that both applications read and write the same data. 两个应用程序不太可能读取和写入相同的数据。 So, instead of sharing the cache, what you could implement is a cache invalidation service (using the communications stack of your choice).
因此,您可以实现的是缓存失效服务 (使用您选择的通信堆栈),而不是共享缓存。
Example: 例:
Customer
data and writes Invoice
data Customer
数据并写入Invoice
数据 Invoice
data and writes Customer
data Invoice
数据并写入Customer
数据 Customer
data and Application B caches Invoice
data Customer
数据,应用程序B缓存Invoice
数据 When Application A, for example, modifies an invoice, it sends a message to Application B and tells it to evict the invoice from the cache. 例如,当应用程序A修改发票时,它会向应用程序B发送一条消息,并告知它从缓存中逐出发票。
You can also evict whole entity types, collections and regions. 您还可以逐出整个实体类型,集合和区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.