RE: [PHP] String to Stream

From: Date: Fri, 05 Aug 2005 19:19:17 +0000
Subject: RE: [PHP] String to Stream
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-220100@lists.php.net to get a copy of this message
Eric Gorr wrote: > Again, I would like to treat the string as a stream. > > One possible way to accomplish this would be to simply write the > string to a temporary file, open the file with fopen and then use > fscanf, fseek, etc. to process the text. > > However, I am assuming there is an easier way (i.e. a method without > the file io overhead) to be able to treat the string as a stream. If you're willing to go the lengths of writing out a temporary file and the overhead is the only thing that is stopping you, AND you are running on Linux, consider using a tmpfs volume (RAM-based) and write your temp files there. That should almost eliminate any overhead of writing the file out. tmpfs is flexible, as it grows (up to a maximum you can set) and shrinks as necessary, and can even have its contents paged out to the swap file if they haven't been accessed in a while. Assuming you've got the RAM to spare, setting one up is as simple as creating a directory and adding an entry to /etc/fstab. I've used tmpfs volumes for similar things in the past with great success. FWIW...

« previous php.general (#220100) next »