If all database access is hidden behind an app layer, you could also have the thread sleep or block on a socket until it gets notified of the appropriate data having been written to the database by another thread (or another application).
Periodically, it could check the database too (like once every 10 minutes) in case something goes wrong with the notification (i.e. the other app crashes - if it's a thread, then that can't happen). Jeff, that comment about wearing a groove into the disk doesn't make any sense. First of all, on a traditional spin disk, this isn't an issue. Even on an SSD, it's the writes that are the issue (& AFAIK, on modern ones this problem has been reduced significantly). Secondly, any database worth its salt would have that data cached in memory anyways (& if it doesn't, then put an index on the column that is being checked to give it a hint), thereby bypassing the disk completely. It might bottleneck other accesses (although unlikely) at which point you can implement one of the above suggestions. But this is a premature optimization - it doesn't require any architectural preparation since the ones I gave are in effect a form of caching. On Sat, May 23, 2009 at 2:13 PM, Jeff Chimene <[email protected]> wrote: > > On 05/23/2009 12:30 AM, Charlie wrote: > > Hey all > > > > I'm building a gwt+php application and I need my client side updated > > every time a database is updated with new data. The way it works right > > now is I'm sending an httprequest to a php script which keeps querying > > the database until there's new data, when there is it sends it back to > > the client and the client makes a recursive call from > > "responseReceived" to the same function which makes the httprequest > > once again and so on it goes.. > > > > Is there any better way to do this? > > > > The answer depends on the problem you're trying to solve. > > There are server push technologies like comet. GWT support for comet has > been discussed frequently on this list. > > The fundamental issue is that such a design will wear a groove into the > disk where the database is stored. Database write notification design is > highly application dependent. To repeat: if you can tell us what problem > you're trying to solve, there may be other answers (although tangential > to GWT and not of much interest to this list). > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
