Benji York skrev: > Jeff Shell wrote: >> We're working on something where we need to allow site visitors to >> rate items. It's the basic star-rating thing. We want to keep a count >> of the number of votes along with the current value. > > At work we've been contemplating an approach for use in some similar > situations we want to address. > > In broad strokes: keep the updated value in memory, write the value to > the database "periodically" (for whatever value of "periodically" is > appropriate for the data). > > This should work well when the value changes often and loosing the most > recent updates to the value isn't catastrophic.
I have used this approach in mxmcounter for zope 2. It keeps a dict in memory, by making it a module attribute.
Every n count it then writes the dict to disk. It has worked on my site for years with no problems.
Only a single problem has been reported by another user. Apparently a zope site crashed while writing the dict, and so left it unreadable.
After restoring the dict on file from backup the site ran fine again. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science Phone: +45 46 93 23 92 Mobile: +45 29 93 42 96 _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users