#!/usr/bin/perl -w
use Cache::Memcached;
use DBI;
use Digest::MD5 qw(md5 md5_hex);
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost", "test", "test", {'RaiseError' => 1});
$dbh->do("set names utf8");
my $sth = $dbh->prepare($ARGV[0]);
$memd = new Cache::Memcached {
'servers' => [ "127.0.0.1:5678","127.0.0.1:5679" ],
'debug' => 0,
'compress_threshold' => 10_000,
};
$sth->execute();
#这里为单一记录,如果结果集,就用set
my @ref=$sth->fetchrow_array();
my $key= md5_hex $ARGV[0];
print "the md5 of sql is $key\n";
print "original value is @ref"."\n";
$memd->set($key, "@ref");
my $val = $memd->get($key);
print "values is $val\n";
阅读(853) | 评论(0) | 转发(0) |