Jump to content

Reading only once


bPHP

Recommended Posts

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!

Link to comment
Share on other sites

  • 2 weeks later...

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);
}

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.