1
votes

I have a question about second level caching with NHibernate and memcache. Suppose the following configuration:

Website A uses DB_A. Data from table X is being cached. Website B uses DB_B. Data from table X is being cached.

Both web apps share a single memcache server.

Now, table X in DB_A and DB_B while having the same schema have different data, so row with PK = 1 in DB_A will NOT be the same data as row with PK = 1 in DB_B.

My question is, will each application clobber the other's data, or is the second level caching smart enough to create cache keys which don't over lap databases.

1
You can define a prefix for the memcache keys so you could just setup both sites to use a different prefix and know that all keys would be A_UserTable or B_UserTable...Phill

1 Answers

2
votes

I'm not sure if you'll have overlapped, overwritten data. You'll need to check what cache-keys are being used. However, interesting reads that you might find helpful:

http://ayende.com/blog/3976/nhibernate-2nd-level-cache

http://ayende.com/blog/3112/nhibernate-and-the-second-level-cache-tips

http://ayende.com/blog/1708/nhibernate-caching-the-secong-level-cache-space-is-shared

The last one is probably of most use to you. The author did something similar to what you are attempting, except you're making your life easier by (somehow) having no primary key conflicts.