On Sat, Apr 8, 2017 at 11:13 AM, Phyambre <phy....@gmail.com> wrote:

> Hi Thiago,
>

Hi!

So if I move the code of the task from onActivate() to setupRender() as
> Geoff suggested, I will not have the task on onSubmit() anymore, so I
> cannot check whether the user finished before the deadline. A solution
> is getting the task from database both on setupRender() and onSubmit(),
> but I don't know if this is more efficient than leave the code in
> onActivate().
>

Yes, it is more efficient, because that code will only be called when you
actually need it.


> The point is, I wanted the task and the stage and the text/quiz to be
> obtained only once from the database, and kept in memory until the user
> finishes the stage. The objects are big and storing them in the session
> may be a bit overkill. Maybe make a cache in the server (concurrent
> HashMap<userId, currentTask>) is the solution? In principle, the number
> of users that can use my app is limited let us say less than 300 so
> maybe such a cache is viable.
>

In both cases, you're storing this big object in the process' memory. I'd
go for a cache.

-- 
Thiago

Reply via email to