LISTEN/NOTIFY

LISTEN/NOTIFY

Post by Cristóv?o Dalla Cos » Sun, 06 Oct 2002 05:50:18



I'm developing an e-commerce site using Apache/mod_perl and, for
performance, I intend to cache rows such as user and product information
inside Perl. I think the LISTEN/NOTIFY interface would be perfect for
invalidating the cache when a product/user gets updated, yet I have not
found a way to access it from Perl -- DBI, or DBD::Pg even, offer no way
to "listen". Also, I don't really like the vanilla Pg. So, my question
to you is, is there another efficient way to accomplish notification of
updates?

Thank you

Cristv?o

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

 
 
 

LISTEN/NOTIFY

Post by Jeff Dav » Sun, 06 Oct 2002 07:02:01


I did something similar using python with a simple "getnotify()" function
(part of the python pg module).

I couldn't find a similar function for perl -- strange.

I think the listening process needs to be a separate process anyway, since I
wouldn't think that an apache process would easily be able to wait for a
notification.

You could just do the cache invalidation process in another language, like
python or C, and all that would do is listen for an update, read the updated
info, and replace the cache. It should be small enough that you don't mind
straying from perl, hopefully.

Of course it is weird that perl doesn't support that. Maybe I missed something
too.

Regards,
        Jeff Davis


Quote:> I'm developing an e-commerce site using Apache/mod_perl and, for
> performance, I intend to cache rows such as user and product information
> inside Perl. I think the LISTEN/NOTIFY interface would be perfect for
> invalidating the cache when a product/user gets updated, yet I have not
> found a way to access it from Perl -- DBI, or DBD::Pg even, offer no way
> to "listen". Also, I don't really like the vanilla Pg. So, my question
> to you is, is there another efficient way to accomplish notification of
> updates?

> Thank you

> Cristv?o

> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?

> http://www.postgresql.org/users-lounge/docs/faq.html

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command


 
 
 

1. Synchronous LISTEN/NOTIFY?

Hi,

Say I have two applications A and B communicating via a postgresql
database. A sends data for B to work on.

How can I get B to _wait_ for a signal from A before proceeding?

Right now it looks like B has to keep polling regularly. So in order for
things to occur in a timely fashion the polling interval has to be
ridiculously short. This means using more CPU than I would like.

Is there a postgresql equivalent of a unix select/accept?

Basically LISTEN doesn't wait. It'll really be nice to have one which does
- lots of cool stuff can be done.

For example, I could have a webapp write trigger another app running as
root- the webapp writes high level stuff to the database, and a run-as-root
app does stuff based on it, this seems to be a more secure. Or I could have
a small app watch some logs for some event, send the data to a database.
Then another small app waits for a trigger and then uses some of that data
to do something else. Or we could even have a database level trigger, so
when a certain criteria is met, the waiting application is triggered.
Basically you now can have apps use the database for instant messaging :).

Is this sort of thing possible with postgresql or even other RDBMs?

Thanks,
Link.

2. Alter Fragment On Table very long...

3. listen/notify argument (old topic revisited)

4. Newbie restore question

5. Any suggestions?

6. LISTEN/NOTIFY benchmarks?

7. Disk Storage

8. LISTEN/NOTIFY

9. DBD::Pg and NOTIFY (was Re: [GENERAL] Synchronous LISTEN/NOTIFY?)

10. NOTIFY/LISTEN Using Embedded SQL (ecpg)

11. problem with notify/listen