Re: too slow to unset big array (after mem fragment)

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

 



On Fri, 21 Jan 2005 11:49:30 -0800 (PST), Richard Lynch <ceo@xxxxxxxxx> wrote:
> 
> Perhaps you could store all data with an index of time rounded off to
> minutes (hours, whatever).
> 
> Example:
> 
> <?php
>  //15 minutes -- Change larger/smaller for more/less frequent purges
>  $purge_time = 60 * 15
>  $now = time();
> 
>  //purge old data:
>  $old = floor($now - $purge_time) / $purge_time);
>  unset($tracker[$old]);
> 
>  //store incoming data:
>  $current = floor($now / $purge_time);
>  $tracker[$current][...whatever you use now...] = ...data...;
> ?>
looks good for GC, but seems bad for "in USE"
whenever there's an incoming new data which is not set in
$tracker[$current][...whatever you use now...], i have to go through
back all chunks of $tracker[] to archive "1hour tracking" effect
for $tracker[...]['site.view'][$siteid], only the first click is new,
cos they click same site
but for $tracker[...]['thread.view'][$threadid], almost all clicks is
new, cos they don't read same thread

each time i roll chunk, current online users make
$tracker[...]['site.view'][$siteid] is double from chunk[new-1] to
chunk[new]
too freq make it too many copies
but i'd guess it's ok for 'thread.view', "cos they don't read same
thread", no double

imagine if u guys write ip tracked(1 ip 1 view) counter, how will u
write the daemon?
database is slow imho


> If you make the $purge_time *TOO* small, smaller than the frequency with
> which the loop runs, then old data will get "missed" and never purged.
no problem, i can do
$expred = floor((time() - 1hour)/$pure_time);
reset(..)
while(list ... each())
  break if $key >= not expired

-- 
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