Skip to content

Instantly share code, notes, and snippets.

@pen
Created July 4, 2016 01:00
Show Gist options
  • Save pen/3ee10aad79ee2701cd7d8f6189e527f6 to your computer and use it in GitHub Desktop.
Save pen/3ee10aad79ee2701cd7d8f6189e527f6 to your computer and use it in GitHub Desktop.
sub get_data
{
my ($self, $key) = @_;
$data = $self->get($key);
$flag = $self->get("$key\::flag");
unless ($flag && $data) {
$self->set("$key\::flag", 1, $self->expire - $self->delta);
...; # do task
$self->set($key, $data, $self->expire);
}
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment