[Petal] Creating template from string
Fergal Daly
fergald at gmail.com
Thu Jul 21 20:09:39 BST 2005
If you just replace the filename with "SCALAR(0x813cd9c)" then you'll
also get an md5 hash appended which would mean that changing the
string would be enough. However using "SCALAR(0x813cd9c)" would mean
that it would not persist between runs.
So to be clever you could do something like
$filename = "//strings/".md5sum("some salt".$string);
the // ensures the filename won't collide with a real file. The md5sum
and the "some salt" means that we have 2 md5sum in the cached filename
making it even less likely to have an md5 hash collision but the
filename for a string will be the same every time we run the program,
F
On 7/21/05, Michael Graham <magog at the-wire.com> wrote:
>
> > One thought though - how will Petal cache the complied version of a
> > template created from a string? Perhaps some sort of 'cache key' could
> > be passed to the constructor?
>
> That's a good question. I initially tried making a Petal subclass that
> didn't need a filename, but I got foiled by all the file caching stuff.
>
> Since we can make strings look like filehandles, would a filehandle work
> just as well?
>
> As for a cache key, maybe you could use "SCALAR(0x813cd9c)" or whatever
> the stringified version of the scalarref's address is? It would mean
> that to change the template you'd have to pass in a new string, not just
> change the existing buffer.
>
>
> Michael
>
>
> --
> Michael Graham <magog at the-wire.com>
>
>
>
More information about the Petal
mailing list