I’ve been using NHibernate for a while now, I’m still wondering what the differences are between the the Second Level Cache Providers ?
- Do some perform better\worse ?
- What is popular and why ?
For clarity I’m talking about:
- NHibernate.Caches.MemCache
- NHibernate.Caches.Prevalence
- NHibernate.Caches.SharedCache
- NHibernate.Caches.SysCache
- NHibernate.Caches.SysCache2
- NHibernate.Caches.Velocity
and I’m sure there are others.
Thanks
Comparing these cache providers effectively boils down to comparing memcached vs prevalence vs Velocity, etc, and that is not really related to NHibernate.
Here are some reasons (by no means a complete list) to pick one over the others:
If you want to keep it simple and don’t run your app in a farm, you might want to use SysCache/Prevalence, which runs in-proc. If you use MS SQL Server, use SysCache2.
If you need a huge cache across many cache-dedicated servers, you might want to use memcached, which can run on Linux so you’d avoid licensing costs.
If your application runs on Azure or already uses AppFabric, you might want to use Velocity.
Personally I prefer to do caching myself at a higher level than data access (only when really necessary), as to make caching more intentional and meaningful than just entities and to embrace more than data access in the cache. In a properly designed system, caching can be easily transparent using decorators or proxies.