CHI::D...astMmap(3pm)

πŸ“¦
version 0.61 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CHI::Driver::FastMmap β€” the perl doc bestie edition πŸ’–

okay so you're here for CHI::Driver::FastMmap (a.k.a. part of the User Contributed Perl Documentation, 3pm section, iykyk). It's the driver that gives you a persistent interprocess cache via mmap'ed files. Let's go ✨


✨ VERSION ✨

version 0.61 β€” she's been through some things and she's thriving πŸŽ€


🌸 SYNOPSIS 🌸

use CHI;

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

look at her. four lines. immaculate. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So this cache driver uses Cache::FastMmap to store data in an mmap'ed file. It's very fast, bestie, like actually fast. You can use it to share data between processes on a single host β€” but not between hosts. Don't try it. She said what she said. 😭

To support namespaces, this driver takes a directory parameter rather than a file, and creates one Cache::FastMMap file for each namespace. One file per namespace, periodt. πŸ‘‘

Because CHI handles serialization automatically, we pass the "serializer" flag as ''; and to conform to the CHI API, we pass "unlink_on_exit" as 0, so that all cache files are permanent. Nothing gets deleted, she's staying, main character energy fr fr. 🌈


πŸŽ€ REQUIREMENTS πŸŽ€

You will need to install Cache::FastMmap from CPAN to use this driver. That's it. That's the requirement. Go get her. 🫢


✨ CONSTRUCTOR OPTIONS ✨

  • 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. πŸ”₯

Any other constructor options not recognized by CHI are passed along to Cache::FastMmap->new. So like, if CHI doesn't know her, FastMmap does. 🀝


πŸ’œ 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 { ... });

it's giving backstage pass to the real object. obsessed. 🌟


🌈 SEE ALSO 🌈

  • CHI β€” the whole entire parent vibe, go read her too πŸ¦‹

πŸ‘‘ AUTHOR πŸ‘‘

Jonathan Swartz <swartz@pobox.com> β€” thank you legend, we stan 🫢✨


This software is copyright (c) 2021 by Jonathan Swartz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So like, it's free free. Slay. πŸ’–


k that's the whole page bestie, no cap. this was perl v5.32.1 realness, dated 2021-10-15, served up as CHI::D...astMmap(3pm) β€” mwah, go cache something πŸ’‹πŸŒΈ

πŸ“¦ where this page comes from