use Cache::FileCache; sub methodname { my $self = shift; my $value = shift; # optional my $cacheKey = "methodname - $self'; # or use $self->id or similar if there is one -- just something unique for this method & instance my $cache = new Cache::FileCache( { namespace=>"YourStuff" } ); if( defined $value ){ $cache->set( $cacheKey, $value, "10 minutes" ); # this could be NEVER_EXPIRE, too } my $result = $cache->get($key); return $result if defined $result; # do actual 'methodname' calculations here. # optionally cache the result: # $cache->set( $cacheKey, $value, "10 minutes" ); }