On Wed, Jul 9, 2008 at 6:11 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote: > generate a unique hash as the name based on the contents of the zip, then > if 2 people > happen to want exactly the same selection you won't have to build/zip it > twice ... > just check if the zip happens to exist before trying to build it. > > have the script do garbage collection on old zip files ... in a script > specific 'tmp' > dir that stores the created zipfiles ... the GC can kick in on 1% of every > requests (and > maybe limits itself the ammount of time spent GCing) > > to elliminate race conditions completely you'll have to use a lock file, > which the script needs to exclusively lock before attempting to create the > zip ... > a failure to get an exclusive lock means having to recheck the zip's > existence > (chances are some other script just created it). in addition a shared lock > should be > obtained before trying to read a zip, to avoid reading half written files. if it is a high traffic site, on a *nix host, i recommend the sem* functions from the sysv extension. theyre a lot faster than file locks. -nathan