The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

CHI::Driver::FastMmap -- Shared memory interprocess cache via mmap'ed files

SYNOPSIS

    use CHI;

    my $cache = CHI->new(
        driver     => 'FastMmap',
        root_dir   => '/path/to/cache/root',
        cache_size => '1m'
    );

DESCRIPTION

This cache driver uses Cache::FastMmap to store data in an mmap'ed file. It is very fast, and can be used to share data between processes on a single host, though not between hosts.

To support namespaces, this driver takes a directory parameter rather than a file, and creates one Cache::FastMMap file for each namespace. Because CHI handles serialization automatically, we pass the raw_values flag.

CONSTRUCTOR OPTIONS

When using this driver, the following options can be passed to CHI->new() in addition to the CHI.

root_dir

Path to the directory that will contain the share files, one per namespace. Defaults to a directory called 'chi-driver-fastmmap' under the OS default temp directory (e.g. '/tmp' on UNIX).

dir_create_mode

Permissions mode to use when creating directories. Defaults to 0775.

Indicates whether Cache::FastMmap should remove the cache when the object is destroyed. We default this to 0 to conform to the CHI API (unlike Cache::FastMmap, which defaults it to 1 if the cache files doesn't already exist).

cache_size
page_size
num_pages
init_file

These options are passed directly to Cache::FastMmap.

METHODS

fm_cache

Returns a handle to the underlying Cache::FastMmap object. You can use this to call FastMmap-specific methods that are not supported by the general API, e.g.

    $self->fm_cache->get_and_set("key", sub { ... });

SEE ALSO

Cache::FastMmap CHI

AUTHOR

Jonathan Swartz

COPYRIGHT & LICENSE

Copyright (C) 2007 Jonathan Swartz.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.