tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid <...@pidster.com>
Subject Re: RV: Session & Context variables architecture problem
Date Thu, 28 Oct 2010 21:36:07 GMT
On 28/10/2010 18:31, falvarez@geocom.com.uy wrote:
> Dear All,
>                 I'm currently using Tomcat 6.0.28 and having some doubt on
> how to solve and implement this problem:
>                                My webapp has a MySQL Database with a table
> named "parameters", in which we have just two columns ("property" and
> "value"). This table is acceded many times but doesn't change often.
> 
>                                For performance purposes I want to save this
> parameters in the user's tomcat session, so they are read from memory and
> not database. So far so good.

Do you actually know that this is a performance problem, or are you
guessing that it is?

>                                Now the problem: how can I tell this sessions
> that an attribute has changed?

Using the session will mean that you have duplicate copies of this
information in each session.

>                 I had suggestions of using "context variables" instead of
> "session variables", but that didn't solve the problem.

*If* you need to do this, using the Context is probably better.

I would suggest that you created a class which periodically updated all
the values by selecting the data in the DB and storing the result in the
Context.

Implementing a ServletContextListener will give you access to the
ServletContext and two methods, for app startup & shutdown, which you
can use to start the periodic process, and properly stop it (very
important).

You may consider using a Timer, or something from the
java.util.concurrent package.


p

> Any help in this matter is more than welcome. I have no problem in changing
> the approach, and may be not use sessions at all.
> 
> Thanks in advance.
> 
> Best regards,
> 
>                 Federico Alvarez.
> 
> Info:
> 
>                 Tomcat 6.0.28
>                 Java 1.6
>                 MySQL 5.5
> 
>                 NOT USING HIBERNATE, so 2nd Level cache is not an option


Mime
View raw message