NAME

Mojo::MemoryMap::Writer - Writer

SYNOPSIS

use Mojo::MemoryMap::Writer;

my $writer = Mojo::MemoryMap::Writer->new(map => $map);
$writer->store({foo => 123});
say $writer->fetch->{foo};

DESCRIPTION

Mojo::MemoryMap::Writer is a scope guard for Mojo::MemoryMap that allows you to write safely to anonymous mapped memory segments.

METHODS

Mojo::MemoryMap::Writer inherits all methods from Mojo::Base and implements the following new ones.

change

my $bool = $writer->change(sub {...});

Fetch data, modify it in the closure and store it again right away.

# Remove a value safely
$writer->change(sub { delete $_->{foo} });

fetch

my $data = $writer->fetch;

Fetch data.

new

my $writer = Mojo::MemoryMap::Writer->new;
my $writer = Mojo::MemoryMap::Writer->new(map => $map);
my $writer = Mojo::MemoryMap::Writer->new({map => $map});

Construct a new Mojo::MemoryMap::Writer object.

store

my $bool = $writer->store({foo => 123});

Store data, replacing all existing data.

SEE ALSO

Mojolicious::Plugin::Status, Mojolicious::Guides, https://mojolicious.org.