The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Plack::Session::Store::Transparent - Session store container which provides transparent access


        use Plack::Builder;
        use Plack::Middleware::Session;
        use Plack::Session::Store::Transparent;
        use Plack::Session::Store::DBI;
        use Plack::Session::Store::Cache;
        use CHI;

        my $app = sub {
                return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
        builder {
                enable 'Session',
                        store => Plack::Session::Store::Transparent->new(
                                origin => Plack::Session::Store::DBI->new(
                                        get_dbh => sub { DBI->connect(@connect_args) }
                                cache => Plack::Session::Store::Cache->new(
                                        cache => CHI->new(driver => 'FastMmap')


This will manipulate multiple session stores transparently. This is a subclass of Plack::Session::Store and implements its full interface.


new ( %args )

The constructor expects the origin argument to be a instance of Plack::Session::Store instance, and cache argument to be a instance of it or an arrayref which contains it, otherwise it will throw an exception. If the cache arguments is an arrayref, the elements of it will be accessed from the first.

fetch ( %session_id )

Fetches session data from caches to origin, and stores the result in outside layers.

store ( %session_id, $session )

Stores session data in all layers (from caches to origin). If one of the layer throw an exception, this method will try to keep consistency between layers, i.e. remove this session from ouside layers.

remove ( %session_id )

Removes session data from all layers (from caches to origin).


A simple accessor for the layers.


Copyright (C) Ichito Nagata.

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


Ichito Nagata <>