.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Mojo::Asset::Memory 3pm" .TH Mojo::Asset::Memory 3pm "2019-02-05" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojo::Asset::Memory \- In\-memory storage for HTTP content .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Mojo::Asset::Memory; \& \& my $mem = Mojo::Asset::Memory\->new; \& $mem\->add_chunk(\*(Aqfoo bar baz\*(Aq); \& say $mem\->slurp; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojo::Asset::Memory is an in-memory storage backend for \s-1HTTP\s0 content. .SH "EVENTS" .IX Header "EVENTS" Mojo::Asset::Memory inherits all events from Mojo::Asset and can emit the following new ones. .SS "upgrade" .IX Subsection "upgrade" .Vb 4 \& $mem\->on(upgrade => sub { \& my ($mem, $file) = @_; \& ... \& }); .Ve .PP Emitted when asset gets upgraded to a Mojo::Asset::File object. .PP .Vb 4 \& $mem\->on(upgrade => sub { \& my ($mem, $file) = @_; \& $file\->tmpdir(\*(Aq/tmp\*(Aq); \& }); .Ve .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" Mojo::Asset::Memory inherits all attributes from Mojo::Asset and implements the following new ones. .SS "auto_upgrade" .IX Subsection "auto_upgrade" .Vb 2 \& my $bool = $mem\->auto_upgrade; \& $mem = $mem\->auto_upgrade($bool); .Ve .PP Try to detect if content size exceeds \*(L"max_memory_size\*(R" limit and automatically upgrade to a Mojo::Asset::File object. .SS "max_memory_size" .IX Subsection "max_memory_size" .Vb 2 \& my $size = $mem\->max_memory_size; \& $mem = $mem\->max_memory_size(1024); .Ve .PP Maximum size in bytes of data to keep in memory before automatically upgrading to a Mojo::Asset::File object, defaults to the value of the \&\f(CW\*(C`MOJO_MAX_MEMORY_SIZE\*(C'\fR environment variable or \f(CW262144\fR (256KiB). .SS "mtime" .IX Subsection "mtime" .Vb 2 \& my $mtime = $mem\->mtime; \& $mem = $mem\->mtime(1408567500); .Ve .PP Modification time of asset, defaults to the value of \f(CW$^T\fR. .SH "METHODS" .IX Header "METHODS" Mojo::Asset::Memory inherits all methods from Mojo::Asset and implements the following new ones. .SS "add_chunk" .IX Subsection "add_chunk" .Vb 2 \& $mem = $mem\->add_chunk(\*(Aqfoo bar baz\*(Aq); \& my $file = $mem\->add_chunk(\*(Aqabc\*(Aq x 262144); .Ve .PP Add chunk of data and upgrade to Mojo::Asset::File object if necessary. .SS "contains" .IX Subsection "contains" .Vb 1 \& my $position = $mem\->contains(\*(Aqbar\*(Aq); .Ve .PP Check if asset contains a specific string. .SS "get_chunk" .IX Subsection "get_chunk" .Vb 2 \& my $bytes = $mem\->get_chunk($offset); \& my $bytes = $mem\->get_chunk($offset, $max); .Ve .PP Get chunk of data starting from a specific position, defaults to a maximum chunk size of \f(CW131072\fR bytes (128KiB). .SS "move_to" .IX Subsection "move_to" .Vb 1 \& $mem = $mem\->move_to(\*(Aq/home/sri/foo.txt\*(Aq); .Ve .PP Move asset data into a specific file. .SS "size" .IX Subsection "size" .Vb 1 \& my $size = $mem\->size; .Ve .PP Size of asset data in bytes. .SS "slurp" .IX Subsection "slurp" .Vb 1 \& my $bytes = mem\->slurp; .Ve .PP Read all asset data at once. .SS "to_file" .IX Subsection "to_file" .Vb 1 \& my $file = $mem\->to_file; .Ve .PP Convert asset to Mojo::Asset::File object. .SH "SEE ALSO" .IX Header "SEE ALSO" Mojolicious, Mojolicious::Guides, .