use Cache::File; ... has _cache => (isa => 'Cache', is => 'rw', default => sub{ new Cache::File(cache_root => '/tmp/cacheroot')}); ... my $value = $self->_cache->get($key); unless ($value) { $value = do_operation(...); $self->_cache->set($key,'1 hour'); } return $value;