Re: Individual bulk e-mails - performance question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2008-08-31 at 21:42 +0200, Jochem Maas wrote:
> Robert Cummings schreef:
> > On Sun, 2008-08-31 at 17:10 +0200, Jochem Maas wrote:
> >> Robert Cummings schreef:
> >>> On Sun, 2008-08-31 at 12:12 +0200, Per Jessen wrote:
> >>>> Robert Cummings wrote:
> >>>>
> >>>>>> That's easily taken care of.  Instead of a cron-job, you could have a
> >>>>>> script running as a daemon, checking for emails to be sent every
> >>>>>> 5mins.
> >>>>> That's the same as running a cron every 5 minutes except now you also
> >>>>> need to detect if your daemon dies :) On the plus side though, you
> >>>>> eliminate the overhead of starting up the script every 5 minutes :)
> >>>> It is not the same as it will prevent multiple scripts running
> >>>> concurrently in case a batch of emails takes longer that 5 minutes. 
> >>>> Checking if the daemon dies - I guess it's a matter of taste or
> >>>> paranoia, but I don't think it's necessary when the script is
> >>>> sufficiently simple:
> >>>>
> >>>> #!/bin/sh
> >>>> while true 
> >>>> do
> >>>>     <yourscript>
> >>>>     sleep 300
> >>>> done
> >>> I accomplish the same with cron scripts by using locks with expiry.
> >> got an example? my cat skinning skills need to be improved, the cat
> >> won't like it but screw the cat, right?
> > 
> > <?php
> > 
> >     $lockName = 'myLockForSomething';
> >     $mLock = &$this->getService( 'lockManager' );
> >     if( !($lock = &$mLock->get( $lockName )) )
> >     {
> >         $age = $mLock->getAge( $lockName );
> >         if( $age > (60 * 60) ) // 1 hour
> >         {
> >             $mLock->forceRemoval( $lockName );
> >         }
> >     }
> > 
> >     if( !($lock = &$mLock->getRef( $lockName )) )
> >     {
> >         exit;
> >     }
> > 
> >     // Do stuff... current process has the lock.
> > 
> >     $lock->destroy();
> > 
> > ?>
> > 
> > Never really thought to until now... but I could easily roll the age
> > check into the lock code itself and pass a parameter to the get()
> > method. It would shrink the above code considerably.
> 
> proves tedd's adage that writing up a decent post always brings about
> some level of insight :-)
> 
> > I implemented my own lock class which uses directory creation and the
> > return value to determine if the lock was successful. Unlike file
> > creation (or so I read several years ago) directory creation is atomic
> > and works across NFS. As an added benefit, I'm able to store lock
> > related data into the lock directory as files.
> 
> interesting, thanks for the feedback.
> 
> I assume that this is coming from your interjinn lib, and that it's
> aimed at php4 (given the ampersands your throwing about)
> 
> also your LockManager object seems to have a get() and getRef()
> method which do the same ... or is that typo?

Lol, I didn't even know that it supported the get() version. I thought
I'd simplify the details when posting and so reimmed off the Ref. To
make a long story long, we all know about PHP4's deficiencies and how
passing objects around caused them to copy. Well when I created
InterJinn I had a need to ensure that objects were always the requested
singleton. As such I created a wrapper class which the non ref version
would return with a single member variable called "do". Do was a
reference to the real object and so passing around the wrapper caused
copies of the wrapper to occur but the original object ref remained
intact since PHP4 returned shallow copies. With PHP5 this is no longer
necessary and so for backwards compatibility objects are returned as
before but the object returned is the requested object which has a
member variable called do that happens to be a reference to itself. The
name "do" was chosen because it makes the code still read well.

So for instance in PHP4 you might do:

   $lock = $mLock->get( $someName )
   $lock->do->destroy();

In PHP5 you might do:

   $lock = $mLock->get( $someName )
   $lock->do->destroy();

   or

   $lock->destroy()

So PHP5 benefits from the better object model, but PHP4 compatibility is
still maintained making the move forward to PHP5 that much easier. The
getRef() option was provided in many cases so that programmers that know
how to properly manage their references could skip the whole wrapper
overhead.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux