Skip to content

Instantly share code, notes, and snippets.

@waffle2k
Created April 15, 2011 13:05
Show Gist options
  • Save waffle2k/921655 to your computer and use it in GitHub Desktop.
Save waffle2k/921655 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use lib ( "." );
use Policy::Memcache;
use Data::Dumper;
my $mc = Policy::Memcache->new;
my $ip = shift;
my $cmd = shift || 'get';
chomp( $ip );
if( $cmd eq 'get' ){
my ($val,$ss) = $mc->get( $ip );
print "$ip:$ss => $val\n";
} elsif( $cmd eq 'increment' ){
# Instantiate a new object, but with the overhead
# of the DNS recursor
$mc = Policy::Memcache->new( -policy => 'ss' );
$mc->increment( $ip );
} else {
die( "Unknown command: $cmd\n" );
}
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment