Persistent Publications, CPU Heavy pub-function, global observers

Hi,

Is there a way to have a publication’s observe cursor persist so that the server doesn’t have to call the CPU heavy tasks in my publication function every time a subscription changes for a user?

I was thinking of having a per-session collection, and a global server side Data.find().observe({…}), so that I wouldn’t have to compute things 10-50 times over per session, since the publications would be re-run regularly.

The computation is that of a group, reduce. It doesn’t make sense to have to recompute all of this, for example, when I want to display the next 20 results to the user.

Thanks.

The thought comes to mind that you could simply use your own little computation cache, i.e. just store the results in a simple (global) map and recompute only when necessary?

yep that’s what I ended up doing, thanks!

1 Like