« lib/Plack/Session/Store/RedisFast.pm
↑ Summary
blib/lib/Plack/Session/Store/RedisFast/Encoder/JSON.pm »
| 1 | package Plack::Session::Store::RedisFast::Encoder::Custom; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use 5.008_005; | ||
| 7 | |||
| 8 | use Plack::Util::Accessor qw( inflate deflate ); | ||
| 9 | |||
| 10 | sub new { | ||
| 11 | my ( $class, $inflate, $deflate ) = @_; | ||
| 12 | return bless { | ||
| 13 | inflate => $inflate, | ||
| 14 | deflate => $deflate, | ||
| 15 | }, $class; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub encode { | ||
| 19 | my ( $self, $thing ) = @_; | ||
| 20 | |||
| 21 | $self->inflate->($thing); | ||
| 22 | } | ||
| 23 | |||
| 24 | sub decode { | ||
| 25 | my ( $self, $bytes ) = @_; | ||
| 26 | |||
| 27 | $self->deflate->($bytes); | ||
| 28 | } | ||
| 29 | |||
| 30 | 1; | ||
| 31 | |||
| 32 | __END__ |