RPC::Switch::Client::Tiny::SessionCache - Session tracking for async childs
use RPC::Switch::Client::Tiny::SessionCache; sub trace_cb { my ($type, $msg) = @_; printf "%s: %s\n", $type, to_json($msg, {pretty => 0, canonical => 1}); } my $cache = RPC::Switch::Client::Tiny::SessionCache->new(trace_cb => \&trace_cb); my $expires = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime(time()+1)); my $session = $cache->session_new({id => '123', expires => $expires}); my $child = {pid => $$, id => '1', start => time(), session => $session}; if ($cache->session_put($child)) { $cache->expire_insert($child->{session}); } if ($child = $cache->session_get($session->{id})) { $cache->expire_remove($child->{session}); } while ($child = $cache->expired_dequeue()) { delete $child->{session}; }
Barnim Dzwillo @ Strato AG
To install RPC::Switch::Client::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm RPC::Switch::Client::Tiny
CPAN shell
perl -MCPAN -e shell install RPC::Switch::Client::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.