In perl version 4, dbmopen cached 64 entries. I've looked at the source
of perl 5, and can see no evidence of a cache in the interface to "tie".
This is of direct interest, since I have a program which needs to update
the value in a GDBM file entry, by appending to it repeatedly. In the
absence of a memory cache, this causes GDBM to blow up - each addition
adds non-recoverable space into the disk file, which increases in size
quadratically. It hit 800 Mb (for approx 3Mb of information) before
failing for lack of disk space.
I wrote a "shim", which does some crude caching, but this requires the
alteration of "tie" calls:
tie %v,MyCache,GDBM_File,$file...
So, to my questions:
1: is the restoration of low-level caching of tied values on a
wish-list (it's not in the level 4 list on perl.com), or is it even
possible any more, given that the GET method has unlimited
permissible side-effects?
2: can anyone think of a way of adding caching to existing tieable
modules without changing the modules themselves or the calling code?
Failing (2):
3: Is it worth adopting a convention to allow a generalised caching
scheme to be added into existing tieable interfaces? I.e. modifying
each of GDBM, NDBM etc?
The only way that springs to my mind is to make, say, GDBM_File a
shadow, so that we have:
package GDBM_File;
@ISA=qw/Real_GDBM_File/;
It should be possible to construct a caching system which slots
itself in by unshifting @GDBM_File::ISA.
Ian
of perl 5, and can see no evidence of a cache in the interface to "tie".
This is of direct interest, since I have a program which needs to update
the value in a GDBM file entry, by appending to it repeatedly. In the
absence of a memory cache, this causes GDBM to blow up - each addition
adds non-recoverable space into the disk file, which increases in size
quadratically. It hit 800 Mb (for approx 3Mb of information) before
failing for lack of disk space.
I wrote a "shim", which does some crude caching, but this requires the
alteration of "tie" calls:
tie %v,MyCache,GDBM_File,$file...
So, to my questions:
1: is the restoration of low-level caching of tied values on a
wish-list (it's not in the level 4 list on perl.com), or is it even
possible any more, given that the GET method has unlimited
permissible side-effects?
2: can anyone think of a way of adding caching to existing tieable
modules without changing the modules themselves or the calling code?
Failing (2):
3: Is it worth adopting a convention to allow a generalised caching
scheme to be added into existing tieable interfaces? I.e. modifying
each of GDBM, NDBM etc?
The only way that springs to my mind is to make, say, GDBM_File a
shadow, so that we have:
package GDBM_File;
@ISA=qw/Real_GDBM_File/;
It should be possible to construct a caching system which slots
itself in by unshifting @GDBM_File::ISA.
Ian