Apache2-WebApp-Plugin-Session-Memcached

 view release on metacpan or  search on metacpan

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    return bless({}, $class);
}

#----------------------------------------------------------------------------+
# create(\%controller, $name, \%data)
#
# Create a new session within the database and set a web browser cookie.

sub create {
    my ($self, $c, $name, $data_ref)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  },
          { type => HASHREF }
      );

    $self->error('Invalid session name')
      unless ($name =~ /^[\w-]{1,20}$/);

    my @servers   = split(/\s*,\s*/, $c->config->{memcached_servers});

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

}

#----------------------------------------------------------------------------+
# get(\%controller, $name)
#
# Takes the cookie unique identifier or session id as arguments.  Returns
# the session data as a hash reference.  

sub get {
    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

}

#----------------------------------------------------------------------------+
# delete(\%controller, $name)
#
# Takes the cookie unique identifier or session id as arguments.  Deletes
# an existing session.

sub delete {
    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

}

#----------------------------------------------------------------------------+
# update(\%controller, $name, \%data);
#
# Takes the cookie unique identifier or session id as arguments.  Updates
# existing session data.

sub update {
    my ($self, $c, $name, $data_ref)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  },
          { type => HASHREF }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    my $cookie = $c->plugin('Cookie')->get($name);

lib/Apache2/WebApp/Plugin/Session/Memcached.pm  view on Meta::CPAN

    return;
}

#----------------------------------------------------------------------------+
# id(\%controller, $name)
#
# Return the cookie unique identifier for a given session.

sub id {
    my ($self, $c, $name)
      = validate_pos(@_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
      );

    $self->error('Malformed session identifier')
      unless ($name =~ /^[\w-]{1,32}$/);

    return $c->plugin('Cookie')->get($name);
}



( run in 0.478 second using v1.01-cache-2.11-cpan-a5abf4f5562 )