Skip to content

Instantly share code, notes, and snippets.

@realdecisions
Created March 3, 2015 22:03
Show Gist options
  • Save realdecisions/134b4d6d593774a7d572 to your computer and use it in GitHub Desktop.
Save realdecisions/134b4d6d593774a7d572 to your computer and use it in GitHub Desktop.
use Plack::Builder;
use Plack::Request;
use Cache::Memcached::Fast;
use JSON::XS;
my $_JSON = JSON::XS->new->utf8;
my $mem = Cache::Memcached::Fast->new({servers=>[qw/127.0.0.1:11211/]});
$mem->set('counter:1',0);
$mem->disconnect_all;
builder {
enable 'AccessLog', logger => sub { };
sub {
my $env = shift;
# my $req = Plack::Request->new($env);
my $id = 1;#$req->parameters->{id};
my $counter = $mem->incr('counter:'.$id);
[200, ['Content-Type'=>'application/json; charset=UTF-8'], [$_JSON->encode({counter=>$counter})]];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment