Dancer2...ry::File(3)

πŸ’– NAME πŸ’–

Dancer2::Core::Role::SessionFactory::File β€” it's giving role for file-based session factories, bestie ✨


🌸 VERSION 🌸

version 2.2.1 πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. this is a specialized SessionFactory role, and its whole ~thing~ is storing session data in files. that's it. that's the vibe. πŸ“βœ¨

the role is the one doing all the heavy lifting with the files themselves, fr fr. classes that consume it? they only gotta handle serialization and deserialization. like, you bring the data-in-and-out, this role brings the file management. teamwork. 🫢

now, if you're a class consuming this, you must satisfy three requirements, no cap, all three, periodt:

  1. _suffix
  2. _freeze_to_handle
  3. _thaw_from_handle

here's the whole lil blueprint so you can see exactly what we mean πŸ‘‡

package Dancer2::Session::XYX;

use Dancer2::Core::Types;
use Moo;

has _suffix => (
    is      => 'ro',
    isa     => Str,
    default => sub { '.xyz' },
);

with 'Dancer2::Core::Role::SessionFactory::File';

sub _freeze_to_handle {
    my ($self, $fh, $data) = @_;

    # ... do whatever to get data into $fh

    return;
}

sub _thaw_from_handle {
    my ($self, $fh) = @_;
    my $data;

    # ... do whatever to get data from $fh

    return $data;
}

1;

see how clean that is?? iconic. you define your _suffix, you pull in the role with with, and you write your two lil handle functions. that's the whole assignment. πŸ’…


✨ ATTRIBUTES ✨

πŸŽ€ session_dir

where the session files get stored. it defaults to "./sessions" if you don't say otherwise. yes, it'll just make a sessions folder right where you're standing. minding its own business. 🌸


πŸ‘‘ AUTHOR πŸ‘‘

Dancer Core Developers β€” the actual legends 🫢


this software is copyright (c) 2026 by Alexis Sukrieh.

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. slay πŸ’–


and that's the whole page, bestie!! 🌈 this was perl v5.42.3, dated 2026-09-20, and it lives in the User Contributed Perl Documentation section, iykyk πŸŽ€βœ¨ bye ily πŸ¦‹
πŸ“¦ where this page comes from