Global data db access and temporary data

View: New views
4 Messages — Rating Filter:   Alert me  

Global data db access and temporary data

by Artur Kraft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Rifers,

I got a conceptual question about the handling of global data. I want to
implement a browser game with rife and therefore each player has
individual data and needs access to global data.
I thought on startup the webapp retrieves all global data from the
database and stores it in a way it can be fast accessed. Maybe one
singleton with access to various hashmaps behind it. That way it would
be present in memory and no db action had to be made for the global data.

But I am not so sure about it now. It seems like every user/webapp
action which involves data has to access the db. What about temporary
data like if you have a sequence of actions. Do you have to save all the
temporary data also to the db? E.g. you have a webapp where you are able
to complete courses and each course consist of ten questions, but you
only show one question at a time. Do have to store every answer in the
db until all ten answers were given, although only the fact if the
course was passed or not is relevant?


hope you can help me out,
Artur


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Global data db access and temporary data

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On 15 Nov 2007, at 08:55, Artur Kraft wrote:

>
> Hi Rifers,
>
> I got a conceptual question about the handling of global data. I  
> want to
> implement a browser game with rife and therefore each player has
> individual data and needs access to global data.
> I thought on startup the webapp retrieves all global data from the
> database and stores it in a way it can be fast accessed. Maybe one
> singleton with access to various hashmaps behind it. That way it would
> be present in memory and no db action had to be made for the global  
> data.
>
> But I am not so sure about it now. It seems like every user/webapp
> action which involves data has to access the db. What about temporary
> data like if you have a sequence of actions. Do you have to save all  
> the
> temporary data also to the db? E.g. you have a webapp where you are  
> able
> to complete courses and each course consist of ten questions, but you
> only show one question at a time. Do have to store every answer in the
> db until all ten answers were given, although only the fact if the
> course was passed or not is relevant?

RIFE applications typically use continuations for temporary data.  
Other possibilities to do this is to use a caching, like Ehcache, or  
to store data in a servlet session.

Hope this helps,

Geert

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Global data db access and temporary data

by Artur Kraft :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply and mentioning Ehcache. As I understand it, I load my global data into the ehcache's CacheManager Singleton and can access it that way. But how can I init the cache on webapp startup rather than when the first user connects to it? Is there a global init method I can use?

And as for the temporary data, I thought continuations are used to provide the user with the possibility to go back one page and have the exact content of the last page, although it gets dynamically created. In my case, I want to make sure, the user can't go back one page. If he tries to go back one page, he should be redirected to the current page.

Just to make it clear: I can store data in a servlet session, where the temporal data would only be stored on the server-side while the user only has identification data stored on his side and an expiration/timeout can be set? Is that directly supported by rife or is the use discouraged?


Sorry for the newbie questions, but I tried to figure it out for myself as much as I can and I am still a bit confused...

best regards,
Artur




Geert Bevin wrote:
On 15 Nov 2007, at 08:55, Artur Kraft wrote:

  
Hi Rifers,

I got a conceptual question about the handling of global data. I  
want to
implement a browser game with rife and therefore each player has
individual data and needs access to global data.
I thought on startup the webapp retrieves all global data from the
database and stores it in a way it can be fast accessed. Maybe one
singleton with access to various hashmaps behind it. That way it would
be present in memory and no db action had to be made for the global  
data.

But I am not so sure about it now. It seems like every user/webapp
action which involves data has to access the db. What about temporary
data like if you have a sequence of actions. Do you have to save all  
the
temporary data also to the db? E.g. you have a webapp where you are  
able
to complete courses and each course consist of ten questions, but you
only show one question at a time. Do have to store every answer in the
db until all ten answers were given, although only the fact if the
course was passed or not is relevant?
    

RIFE applications typically use continuations for temporary data.  
Other possibilities to do this is to use a caching, like Ehcache, or  
to store data in a servlet session.

Hope this helps,

Geert

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com




  

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Global data db access and temporary data

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Artur,

> Thanks for the reply and mentioning Ehcache. As I understand it, I  
> load my global data into the ehcache's CacheManager Singleton and  
> can access it that way. But how can I init the cache on webapp  
> startup rather than when the first user connects to it? Is there a  
> global init method I can use?

You can create a RIFE participant that will initialize the cache at  
application startup, as for example used in Bla-bla List:

http://rifers.org/fisheye/browse/rifers/blablalist/trunk/src/java/blablalist/participants/OSCacheParticipant.java?r=HEAD

http://rifers.org/fisheye/browse/rifers/blablalist/trunk/src/rep/participants.xml?r=HEAD

> And as for the temporary data, I thought continuations are used to  
> provide the user with the possibility to go back one page and have  
> the exact content of the last page, although it gets dynamically  
> created. In my case, I want to make sure, the user can't go back one  
> page. If he tries to go back one page, he should be redirected to  
> the current page.

No, that's just one of the benefits. Continuations use the local  
variable scope to create state that is preserved on the server across  
requests, without you having to manually manage it. When the  
continuation tree is clear, either explicitly or through a time-out,  
the state is cleared also. The other advantage of continuations, is  
that you can native Java control statements to write the workflow of  
your web application instead of having to model this out into distinct  
actions/components.

> Just to make it clear: I can store data in a servlet session, where  
> the temporal data would only be stored on the server-side while the  
> user only has identification data stored on his side and an  
> expiration/timeout can be set? Is that directly supported by rife or  
> is the use discouraged?

It is supported, but you need to turn raw access on:

http://rifers.org/docs/api/com/uwyn/rife/engine/ElementSupport.html#setProhibitRawAccess(boolean)

or by overriding:

http://rifers.org/docs/api/com/uwyn/rife/engine/ElementSupport.html#prohibitRawAccess()

After that you can use:

http://rifers.org/docs/api/com/uwyn/rife/engine/ElementSupport.html#getHttpServletRequest()

and directly interact with the session.

> Sorry for the newbie questions, but I tried to figure it out for  
> myself as much as I can and I am still a bit confused...

No worries, this is what the list is for :-)

Take care,

Geert

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price
 
 
 
Google
rifers.org web