#
gedw99
Hey,
I need to scale out to 2 web servers connected to a single db.
i am wondering about the caching and state management issues.
If a row is added in the DB by server01, server02 wont see it UNTIL it refreshes it cache right?
So when will it do that?
For example in this code, sure its caching, but where is the time that its cached for. I think there is somehting i am missing about nhibernate here.
public Node GetNodeByShortDescriptionAndSite(string shortDescription, Site site)
{
ISession session = this._sessionManager.OpenSession();
string hql = "from Node n where n.ShortDescription = :shortDescription and n.Site.Id = :siteId";
IQuery q = session.CreateQuery(hql);
q.SetString("shortDescription", shortDescription);
q.SetInt32("siteId", site.Id);
q.SetCacheable(true);
q.SetCacheRegion("Nodes");
IList results = q.List();
if (results.Count == 1)
{
return (Node)results[0];
}
else if (results.Count > 1)
{
throw new Exception(String.Format("Multiple nodes found for ShortDescription {0}. The ShortDescription should be unique.", shortDescription));
}
else
{
return null;
}
}
And what about state between requests? Does the load balancer HAVE TO use "Sticky" or is round robin ok.
I am kind of confused how under the hood NHibernate manages it state you see.
Ged
I need to scale out to 2 web servers connected to a single db.
i am wondering about the caching and state management issues.
If a row is added in the DB by server01, server02 wont see it UNTIL it refreshes it cache right?
So when will it do that?
For example in this code, sure its caching, but where is the time that its cached for. I think there is somehting i am missing about nhibernate here.
public Node GetNodeByShortDescriptionAndSite(string shortDescription, Site site)
{
ISession session = this._sessionManager.OpenSession();
string hql = "from Node n where n.ShortDescription = :shortDescription and n.Site.Id = :siteId";
IQuery q = session.CreateQuery(hql);
q.SetString("shortDescription", shortDescription);
q.SetInt32("siteId", site.Id);
q.SetCacheable(true);
q.SetCacheRegion("Nodes");
IList results = q.List();
if (results.Count == 1)
{
return (Node)results[0];
}
else if (results.Count > 1)
{
throw new Exception(String.Format("Multiple nodes found for ShortDescription {0}. The ShortDescription should be unique.", shortDescription));
}
else
{
return null;
}
}
And what about state between requests? Does the load balancer HAVE TO use "Sticky" or is round robin ok.
I am kind of confused how under the hood NHibernate manages it state you see.
Ged