使用 %
use MRedis
my %h = %{ from_json( rget( $uaString ,\&parser,[$uaString] ) ) };
使用脚本 MRedis.pm
- #!/usr/bin/perl
- use Redis ;
- use JSON ;
- use Data::Dumper;
- my $r = Redis->new;
- sub rget{
- my ($key,$fun,@params) = @_;
- if( $r->exists($key) ){
- return $r->get($key);
- }else{
- #print Dumper $fun->($param) ;
- my $value = to_json( {$fun->(@params)} ) ;
- $r->set( $key => $value );
- return $r->get($key);
- }
- }
阅读(2094) | 评论(0) | 转发(0) |