You are here: Re: Storing file information in memory « PHP Programming Language « IT news, forums, messages
Re: Storing file information in memory

Posted by Steve on 11/15/07 21:49

"deciacco" <a@a> wrote in message
news:c6318fb5a59c46bf8a1e094964de9d6e@ghytred.com...
> I'm writing a command line utility to move some files. I'm dealing with
> thousands of files and I was wondering if anyone had any suggestions.
>
> This is what I have currently:
>
> $arrayVirtualFile =
> array( 'filename'=>'filename',
> 'basename'=>'filename.ext',
> 'extension'=>'ext',
> 'size'=>0,
> 'dirname'=>'',
> 'uxtimestamp'=>'');
>
> I then loop through a directory and for each file I populate the
> $arrayVirtualFile
> and add it to $arrayOfVirtualFiles.
> A directory of ~2500 files takes up about ~1.7 MB of memory when I run
> the script.
> Anyone have any suggestions as to how to take up less space?

well, that all depends what you're doing with that information. plus, your
array structure is a must point. why not just store the file names in an
array. when you need all that info, just use the pathinfo() function. with
just that, so far you have the file name, basename, extension, path...all
you need now is to call fstat() to get the size and the touch time. that
should knock down your memory consumption monumentally. plus, using pathinfo
and fstat will give you a bunch more information that your current
structure.

so, store minimally what you need. then use functions to get the info when
you need it. but again, you should really define what you're doing this all
for...as in, once you have that info, what are you doing?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация