NHibernate SysCache storage - asp.net

I am using Nhibernet with SysCache Provider for second level cache in an Asp.net MVC 4 application. Somewhere i found that SysCache use ASP.Net default cache system to store the cache items. To reduce the use of my limited RAM, i have implemented my custom cache provider which store data in MongoDB.
Now my question is, as i am using my custom cache provider using mongodb, where will be the nhibernet second level cache data stored? Is in mongodb by my custom cache provider or it still will be in RAM?
By the way, my ultimate target is, i want the NHibernet second level cache using SysCache or any other free cache provider but not want to store the cache items in RAM rather in mongodb. Please give a better suggestion to achieve it.
regard
Habib

Now my question is, as i am using my custom cache provider using mongodb, where will be the nhibernet second level cache data stored?
As you have already developed mongo's SLC and if you change settings the data will be probably in mongo ... ?
The point of caching is to provide faster way how to obtain/fetch frequent data than select them from original database.
Your approach makes perfect sense to work correctly with limited memory but I'm not sure whether it will improve the performance of your application how the point of SLC would require.
You store cached data as document/blob in mongo? Have you compare performance against original cache and w/o cache?
If your solution would be successful it requires to develop mongo's cache better than your original queries against RDBMS. This does not have to be true by default. Depends on your purpose and queries you use.

Related

How to make sure realm io user can only access certain data in a model

I'm still learning how to implement realm.io in my next project. I'm really amazed in the Realm Mobile Platform (offline-sync).
I'm reading https://realm.io/docs/realm-object-server/#access-control but what I need is preventing user accessing certain data in a model. (let's say they only can access data only their own data).
Thank You
In addition to the Realm documentation. There are a couple overviews on Multi-Realm setups you could check out. They go over permissions and database design.
https://realm.io/docs/tech-notes/multi-realm-cheatsheet/
https://realm.io/docs/tech-notes/teamwork/

How can I use caching to improve performance?

My scenario is : WebApp -> WCF Service -> EDMX -> Oracle DB
When I want to bind grid I fetch records from Oracle DB using EDMX i.e LINQ Query. But, this degrades performance as multiple layers take place between WebApp & Oracle DB. Can I use caching mechanism to improve the performance? But as far as I know cache is shared across the whole application. So, if I update cache other user might receive wrong information. Can we use caching per user? Or is there any other way to improve performance of the application?
Yes, you can definitely use caching techniques to improve performance. Generally speaking, caching is “application wide” (or it should be) and the same data is available to all users. But this really depends on your scenario and implementation. I don't see how adding the extra caching layer will degrade performance, it's a sound architecture and well worth the extra complexity.
ASP.NET Caching has a concept of "cache dependencies" which is a method to notify the caching mechanism that the underlying source has changed, and the cached data should be flushed and reloaded on the next request. ASP.NET has a built-in cache dependency for SQL Server, and a quick Google search revealed there’s probably also something you can use with Oracle.
As Jakob mentioned, application-wide caching is a great way to improve performance. Generally user context-agnostic data (eg reference data) can be cached at the application level.
You can also cache user context data by storing data in the user's session when they login. Then the data can be cached for the duration of that users session (HttpContext.Session)
Session data can be configured to be stored in the web application process memory, in a state server (a special WCF service) or in a SQL Server database, depending on the architecture and infrastructure.

ASP.NET 4.0 Object Caching

There are two kind of caches that need to be implemented: Global and Session Level.
The session level cache will store certain user specific data like Cart Items, user priviliges etc.
The global cache will store some data common to all the users in a subdomain.
So each subdomain will have a seperate global cache and each user(logged or not) might have a session/user specific cache.
I am thinking of using object caching features provided in 4.0 version of framework using System.Runtime.Caching. Wrapping the basic functionality inside a custom entity.
Another thing that comes to my mind is that the singleton pattern might do the trick, not sure though.
Also to keep in mind that the Website is hosted on a web farm.
Anyone can suggest how to go about this or point me in the right direction on how to implement this?
If your site is on a web farm, then you might consider using Memcached. It's a in-memopy key=>value caching. All you have to do is prefix your session-level cached objects with the sessionID.
I think you should use distributed cache like NCache where you can keep one cache for storing sessions and the second cache for storing the objects. There is a session store provider module that you can plug in with your application and it will store the sessions in an outproc distributed cache automatically. And, you can also store your objects in a key-value pair either in the same cache or different cache by using the API.
There is a free edition available for NCache that you can download and play with
http://www.alachisoft.com

Improve performance on ProfileManager.GetAllProfiles when using SqlProfileProvider

I am using the SqlProfileProvider to store my user profiles in an asp.net web application.
What I am looking for is a way to fetch all user profiles (I would prefer a search API, but there is not one available) with some reasonable performance.
Using the ProfileManager.GetAllProfiles kills the performance of my application.
I was thinking of using Sql Cache Dependency on the object that returns from this method, but I would still have a very slow site every time someone updates a profile (which could happen several times a day).
Anyone have a suggestion to improve the performance? I am looking for things on these lines:
Caching efficiently (only the differences should be re-cached)
Optimizing the GetAllProfiles call
Being able to search profiles, instead of having to fetch them all and filtering later
The sqlProfileProvider does not provide an easy way to search profiles as all profile data is stored in a single column.
You should consider creating your own profile provider or use something like the Table Profile Provider. This stores each profile property in its own database column and so you could easily write custom queries to search the data.

asp.net session using sql server mode

I am using a ASP.net session in SQL Server mode. I have created the necessary tables and stored procs in a custome db
My question is:
Can I use this database to serve more than one application / web site ?
Is there anything to take into consideration having multiple websites use the same db for their session store
cheers
Yes you can use this database to server more than one site. The session provider will take care of the semantics of that.
It would make the profiling more difficult if there is a performance problem. Why not create a second state db for the second application? It's not much to do, simple with a different name and specify the different db in your session configuration.
The short answer though is you can use the same session database and each session should be fine, though I wonder if anyone has any comments on colliding sessionIds between the two applications.

Resources