bPHP Posted March 5, 2010 Share Posted March 5, 2010 How can I read from a certain table only once after it's changed? I'm constantly reading from a table because I need to display it, but I'm not sure how to avoid reading from it when it hasn't been updated (it can be updated from many sources). Any suggestions? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/ Share on other sites More sharing options...
bPHP Posted March 6, 2010 Author Share Posted March 6, 2010 No ideas? Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1022412 Share on other sites More sharing options...
fenway Posted March 15, 2010 Share Posted March 15, 2010 Caching? Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1026468 Share on other sites More sharing options...
bPHP Posted March 23, 2010 Author Share Posted March 23, 2010 How? I still need to check if the table was updated? I'm kind of noobish with this Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1030370 Share on other sites More sharing options...
ignace Posted March 23, 2010 Share Posted March 23, 2010 From which sources is this table updated? And how? If all these different sources use your API just different components then you can abstract a method that will invalidate/update the cache file something like: abstract class MySource { final public function store($data) { $this->_store($data); $this->_update(); } private function _update() { /* invalidate/update cache */ } abstract protected function _store($data); } Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1030397 Share on other sites More sharing options...
bPHP Posted March 23, 2010 Author Share Posted March 23, 2010 This table keeps some kind of interaction between users... Like a chat between users. When one of the users types something and then sends it, this is saved to the database, inside the interaction table of those two users. Right now I think my design is pretty bad; I am using Ajax to constantly call a php function that reads from the interaction table, gets the last message and displays it. I don't really know how to avoid having to constantly refresh or how to know when to go to the database for new changes (like a message sent from the other user). Is my problem clear? Please tell me if I haven't explained it well enough... Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1030459 Share on other sites More sharing options...
fenway Posted March 23, 2010 Share Posted March 23, 2010 Seriously, read about caching. Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1030553 Share on other sites More sharing options...
ignace Posted March 23, 2010 Share Posted March 23, 2010 I suddenly come to think about something how about the following setup: 1. Client: An IFrame that loads the XML file and applies an XSLT template 2. A stored XML file only known to A and B Now everytime a user submits it modifies the XML file (append node). Both clients refresh the IFrame at regular intervals. I wonder what other downsides this could have besides privacy/security? Would there be any gain performance wise? Because this would be the equivalent of multiple databases instead of many people searching (query) through one database each session would have it's own "database" Quote Link to comment https://forums.phpfreaks.com/topic/194271-reading-only-once/#findComment-1030633 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.