The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

RPC::Switch::Client::Tiny::SessionCache - Session tracking for async childs

SYNOPSIS

  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};
  }

AUTHORS

Barnim Dzwillo @ Strato AG