Cache-FastMmap

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


1.17  Thu Aug 22 17:14 2007
  - fix declaration in C code that wasn't legal C

1.16  Thu May 8 17:12 2007
  - fix typo in Changes file (1.15 is 2007, not 2006)
  - fix get_keys(2) when undef values in cache
  - fix some leak detection tests

1.15  Thu May 8 17:12 2007
  - catch and rethrow die/exceptions in get_and_set() callbacks
  - avoid undef warnings when using cache_not_found mode
  - use unique tempfile name rather than the same every time
  - add allow_recursive option to allow calls to cache
    from within a read/write callback sub
  - add checks to die if we try and lock a cache twice,
    rather than just causing mysterious errors
  - add unlink_on_exit to automatically delete the share_file
    when the cache exits. default to true if we created
    the share_file, false if we connected to an existing one
  - make empty_on_exit only call empty if the pid of the

lib/Cache/FastMmap.pm  view on Meta::CPAN

=item *

On each C<set()>, if there are slots and page space available, only
the slot has to be updated and the data written at the end of the used
data space. If either runs out, a re-organisation of the page is
performed to create new slots/space which is done in an efficient way

=back

The class also supports read-through, and write-back or write-through
callbacks to access the real data if it's not in the cache, meaning that
code like this:

  my $Value = $Cache->get($Key);
  if (!defined $Value) {
    $Value = $RealDataSource->get($Key);
    $Cache->set($Key, $Value)
  }

Isn't required, you instead specify in the constructor:

lib/Cache/FastMmap.pm  view on Meta::CPAN


Size of each page. Must be a power of 2 between 4k and 1024k. If not,
is rounded to the nearest value.

=item * B<num_pages>

Number of pages. Should be a prime number for best hashing

=back

The cache allows the use of callbacks for reading/writing data to an
underlying data store.

=over 4

=item * B<context>

Opaque reference passed as the first parameter to any callback function
if specified

=item * B<read_cb>

lib/Cache/FastMmap.pm  view on Meta::CPAN

    eval { $write_cb->($Self->{context}, $_[1], $Val); };
  }

  return $Found;
}

=item I<clear()>

Clear all items from the cache

Note: If you're using callbacks, this has no effect
on items in the underlying data store. No delete
callbacks are made

=cut
sub clear {
  my $Self = shift;
  $Self->_expunge_all(1, 0);
}

=item I<purge()>

Clear all expired items from the cache

Note: If you're using callbacks, this has no effect
on items in the underlying data store. No delete
callbacks are made, and no write callbacks are made
for the expired data

=cut
sub purge {
  my $Self = shift;
  $Self->_expunge_all(0, 0);
}

=item I<empty($OnlyExpired)>



( run in 0.773 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )